Hall Magnetic Sensor Module(KY-024)

아두위키 : Arduwiki

The KY-024 is a magnetic sensor module that offers both digital and analog outputs. It features an adjustable sensitivity via a potentiometer.

Specifications

  • Operating Voltage: 3.3V ~ 5V
  • Output Type: Digital, Analog

Example Required Hardware

  • Arduino board
  • Jumper cables
  • Hall magnetic sensor module (KY-024)

Connection

Arduino KY-024 Hall magnetic sensor module
A0 AO
D12 DO
3.3V +
GND G

Example Code

The example demonstrates how to read values from the Hall magnetic sensor, outputting them in both analog and digital formats.

const int analogPin = A0;
const int digitalPin = 12;

void setup() {
  pinMode(digitalPin, INPUT);
}

void loop() {
  int valap = analogRead(analogPin);
  int valdp = digitalRead(digitalPin);
  Serial.print(valap);
  Serial.print("\t");
  Serial.println(valdp);
  delay(100);
}

Execution Results

  • When no magnet is present around the module
  • When a magnet is present around the module