Instructions

KY-003 Hall Magneticfield-Sensor module
Pinout
Code example Arduino
This example will light up a LED as soon as the sensor is near a magnetic field.
The module KY-011, KY-016 or KY-029 can be used as a LED.
int Led = 13 ;// Declaration of the LED-output pin
int Sensor = 10; // Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
{
pinMode (Led, OUTPUT) ; // Initialization output pin
pinMode (Sensor, INPUT) ; // Initialization sensor pin
digitalWrite(Sensor, HIGH); // Activating internal pull-up resistor
}
void loop ()
{
val = digitalRead (Sensor) ; // The current signal at the sensor will be read.
if (val == HIGH) // If a signal was detected, the LED will light up.
{
digitalWrite (Led, LOW);
}
else
{
digitalWrite (Led, HIGH);
}
}
Connections Arduino:
LED + = [Pin 13]
LED - = [Pin GND]
Sensor Signal = [Pin 10]
Export: 16.06.2017 Copyright by Joy-IT - Published under CC BY-NC-SA 3.0 Page 20 of 214