KY-025 REED SWITCH MODULE

Click Here to View Step by Step

KY-025 REED SWITCH MODULE


Short description :

The KY-025 Reed Switch Module is a small electrical switch operated by an applied magnetic field, commonly used as a proximity sensor.

Working with  (Compatible)

Arduino, ESP32, Nodemcu, ESP8266, Raspberry Pi, and ......

KY-025 REED SWITCH MODULE

KY-025 REED SWITCH MODULE

ARDUINO IDE CODE 

Example description :

we’ll read values from both digital and analog interfaces on the KY-025, you’ll need a magnet to interact with the module..

int led = 13; // define the LED pin
int digitalPin = 3; // KY-025 digital interface
int analogPin = A0; // KY-025 analog interface
int digitalVal; // digital readings
int analogVal; //analog readings
void setup()
{
  pinMode(led, OUTPUT);
  pinMode(digitalPin, INPUT);
  //pinMode(analogPin, OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  // Read the digital interface
  digitalVal = digitalRead(digitalPin); 
    analogVal = analogRead(analogPin); 
  if(analogVal < 10) // if magnetic field is detected
  {
    digitalWrite(led, HIGH); // turn ON Arduino's LED
  }
  else  if(analogVal > 11)
  {
    digitalWrite(led, LOW); // turn OFF Arduino's LED
  }
  // Read the analog interface

  Serial.println(analogVal); // print analog value to serial
  delay(100);
}