Reed switch is used in many of the real-life applications such as magnetic door switch, laptops, smartphones etc. In this tutorials, we will learn about Reed Switch and guide you, how to Interface a Reed Switch with Arduino.
Step 1: Things You NeedTo 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.
Step 3: CodePlease 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);elsedigitalWrite(LED, HIGH);delay(1000);}
Step 4: Reed Switch in ActionAfter 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.
Comments
Please log in or sign up to comment.