Interfacing KY-021 Magnetic Reed Switch module with Arduino

Introduction

The Interfacing KY-021 Magnetic Reed Switch module with Arduino, KY-021 Magnetic Reed Switch module is an electronic component that can detect the presence of a magnetic field and output a digital signal. This module is highly sensitive and can be used in various DIY electronics and hobbyist projects. It is a simple and affordable module that can be integrated with other electronic components to create a variety of applications.

This module is compatible with popular electronic platforms like Arduino, ESP32, Raspberry Pi, and other microcontrollers. and For the analog output check the KY-025 reed switch.

Hardware Required

You will require the following Hardware Components for the Interfacing of the KY-021 Magnetic Reed Switch module with arduino.

Components#Buy From Amazon
Arduino UNO1Buy Now
KY-021 Magnetic Reed Switch module1Buy Now
LED 5mm1Buy Now
Jumper WiresFewBuy Now
Breadboard1Buy Now

What is the KY-021 Magnetic Reed Switch module?

The KY-021 Magnetic Reed Switch module is an electronic component that can detect the presence of a magnetic field and output a digital signal. The module is composed of a PCB board, a reed switch, a resistor, and a few other electronic components. The module can detect the presence of a magnetic field and output a digital signal that can be read by a microcontroller or other electronic components.

KY-021-Magnetic-Reed-Switch-module

Specifications

The module is composed of a PCB board, a reed switch, a 10kΩ resistor, and 3 male header pins.

Operating Voltage3.3V ~ 5V
Current Consumption<10mA
SensitivityHigh
Output SignalDigital (High/Low)
Board Size18.5mm x 15mm [0.728in x 0.591in]

Features

  1. Highly sensitive to magnetic fields
  2. Low power consumption
  3. Easy to integrate with other electronic components
  4. Affordable and widely available
  5. Long lifespan and reliable performance

Pinout

KY-021-Magnetic-Reed-Switch-module-Pinout

Pin Configuration

Pin NamePin Type
SSignal
middleVCC
GND

Circuit Diagram

The following circuit shows you the connection of the KY-021 Magnetic Reed Switch module with Arduino Please make the connection carefully

KY-021-Magnetic-Reed-Switch-module-Interfacing-with-Arduino-circuit

Circuit Connections

ArduinoModule
Pin 2S Pin
+5Vmiddle Pin
GND(-) GND Pin

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code

//For more Projects: www.arduinocircuit.com
int led = 13; // LED pin
int reelSwitch = 2; // magnetic senso rpin
int switchState; // variable to store reel switch value
void setup() 
{
  pinMode (led, OUTPUT);
  pinMode (reelSwitch, INPUT);
}
void loop()
{
  switchState = digitalRead(reelSwitch); // read the value of digital interface 2 and assign it to switchState
  
  if (switchState == HIGH) // when the magnetic sensor detect a signal, LED is flashing
  {
    digitalWrite(led, HIGH);
  }
  else 
  {
    digitalWrite(led, LOW);
  }
}

Applications

  1. DIY electronic projects
  2. Security systems
  3. Magnetic door and window sensors
  4. Industrial automation
  5. Smart homes and home automation

Conclusion

The KY-021 Magnetic Reed Switch module is a highly sensitive and affordable electronic component that can detect the presence of a magnetic field and output a digital signal. With its low power consumption, easy integration with other electronic components, and long lifespan, it is a popular choice for DIY electronics enthusiasts and hobbyists. Whether you’re building a security system, a smart home automation device, or an industrial automation system, the KY-021 Magnetic Reed Switch module is a versatile and useful component that can help bring your projects to life.

Leave a Comment


error: