Reed Switch With Arduino

by Utsource in Circuits > Arduino

1196 Views, 0 Favorites, 0 Comments

Reed Switch With Arduino

Reed-switch-with-Arduino-in-action.jpg
Reed switch is used in many of the real-life applications such as magnetic door switch, laptops, smartphones etc. In this instructables, we will learn about Reed Switch and guide you, how to Interface a Reed Switch with Arduino.

Things You Need

Reed-Switch.jpg
Km5Zu-2RIncAUweU7uG7IhyWPySZ0SqIgAI0-vk9w7767_IkthCPCcsirj2GGmXF4IdQDg8UVpHVLVM6CXnzFsG1hnAdSkK7BIhIOtEldXoZiDsvzsPo-6o0rD6Mda7UyOE=w456-h323-nc.png
electronics-kit-resistor-led-button-breadboard-wire-1697-1024x1024.jpg

For this instructables we will need following things :

Arduino Uno
Reed switch
Resistors
LED
Magnet
Connecting wires
Breadboard

Schmatics

20191104_202029.jpg
To interface reed switch with Arduino we need to build a voltage divider circuit as shown in the figure below. Voltage is +5V when the switch is open and 0V when the switch is closed. We are using a normally open reed switch in this project. Switch is closed in the presence of magnetic field and it is open in the absence of magnetic field.

Code

images(101).jpg

Please copy the following code and upload it to the arduino Board :

int LED = 7;
int reed_switch = 4;
int reed_status;
void setup()
{
pinMode(LED, OUTPUT);
pinMode(reed_switch, INPUT);
}
void loop()
{
reed_status = digitalRead(reed_switch);
if (reed_status == 1)
digitalWrite(LED, LOW);
else
digitalWrite(LED, HIGH);
delay(1000);
}

Reed Switch in Action

Reed-switch-with-Arduino-in-action.jpg
After connecting everything together and uploading the code to your arduino so whenever i put a magnet near to the reed switch it gets triggered and LED turns ON.