22
Hall Effect Sensor
KY-003
Hall Effect Sensor (KY-003)
No. 22 • Digital

Hall Effect Sensor (KY-003)

ตรวจจับแม่เหล็กด้วย Hall effect sensor

Component NameHall Effect Sensor
Part No. / ModelKY-003
Interface TypeDigital
PinsS, VCC, GND

Note: ใช้แม่เหล็กถาวรเข้าใกล้เพื่อทดสอบสัญญาณ

Wiring Example

ตัวอย่างการต่อวงจรกับ Arduino UNO

Circuit diagram
Sensor PinArduino Pin
SD2
VCC5V
GNDGND

Arduino IDE Code

Download .ino file

ky-003-hall.ino
// Hall Effect Sensor (KY-003)
// Board: Arduino UNO
// Read digital output from the sensor module.

const int SENSOR_PIN = 2;

void setup() {
  Serial.begin(9600);
  pinMode(SENSOR_PIN, INPUT);
}

void loop() {
  int state = digitalRead(SENSOR_PIN);
  Serial.print("Sensor state: ");
  Serial.println(state);
  delay(300);
}