ARDUINO REED SWITCH Tutorial – How to use Arduino REED SWITCH
Arduino REED Switch Tutorial
Hello guys, welcome back to my blog. This tutorial includes what is the Arduino Reed switch and how does works Arduino Reed switch. We can use this reed switch for security systems, alarm systems, automotive projects, refrigerator doors.
The Reed switch is an electromagnetic switch. These are used to control the current in a circuit. This reed switch is made by inserting two or more ferrous tubes into a small glass tube. When a magnetic field is carried near this switch, the ferrous Reeds become magnetic. Then these tubes touch each other. Then electricity begins to flow through this. When the magnetic field is removed again, the reeds return to their previous state. Then the electricity stops flowing. This Reed switch acts as a gate in a circuit. We can easily control this Reed switch by magnetic fields.
There are two types of reed switches.
1.Normally open Reed switch.
This includes two tubes made of ferrous material. When a magnet is carried near this, one tube is pulled by the other. Then the circuit is completed and electricity passes through it. When the magnet is removed, it returns to its previous state.
When there is no magnetic field, the tubes touch each other and complete the circuit. Also, when a magnet is placed near this, the tube is repulsed and the circuit is disconnected.
Well, now we will test the functionality of this using the module created by inserting this Reed switch. Here we can see 3 main pins. We can also get a digital signal through this. The potentiometer here can change the sensitivity of the digital value.
Do — Digital signal can be obtained through this.
VCC – This should be given a 5v potential.
GND — Ground of this module.
The accessories required for this project are as follows.
/*Reed sensor with Arduino UNO board.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
https://srituhobby.com/
*/
#define Sensor 5
#define LED 6
void setup() {
Serial.begin(9600);
pinMode(Sensor, INPUT);
pinMode(LED, OUTPUT);
}
void loop() {
bool value = digitalRead(Sensor);
Serial.println(value);
if (value == 0) {
digitalWrite(LED, HIGH);
Serial.println("LED on");
} else {
digitalWrite(LED, LOW);
}
}
Code explanation
Here we first define the Arduino PINs that connect the sensor and the LED.
#define Sensor 5
#define LED 6
In the void loop, the LED pin is set to the OUTPUT pin and the sensor pin to the INPUT pin.
void setup() {
Serial.begin(9600);
pinMode(Sensor, INPUT);
pinMode(LED, OUTPUT);
}
In the void loop, the sensor value is read and inserted into the Boolean variable called “value”. Also, check that value with an if condition, and if its value is 0 then the LED is active, and if not the LED is off.
void loop() {
bool value = digitalRead(Sensor);
Serial.println(value);
if (value == 0) {
digitalWrite(LED, HIGH);
Serial.println(“LED on”);
} else {
digitalWrite(LED, LOW);
}
}
Step 4
Finally, select the board and port. Then, upload this code to the Arduino board.
Now you can check out this project. Use a magnetic part for that. The full video guide is below. We will meet in the next tutorial.
Servo motor control using ESP8266 Blynk Hello, welcome back. This tutorial is based on IoT and covers how to control a servo motor using ESP8266 and the…
Hello and welcome back. In this project, we will learn how to make a smart irrigation system with an Arduino UNO R4 WIFI board. For that, I mainly used the…
Hello and welcome back. In this project, we will learn how to make a DIY motion protection system with the Nodemcu ESP8266 board. This DIY project is perfect for those…
Hello and welcome back. In this tutorial, we will learn how to use the 16-channel PWM servo motor driver with a Raspberry Pi board. For that, I have used the…
Hello guys, welcome back to another blog from the SriTu Hobby. So, In this article, we will learn how to make a Smart dustbin using Arduino. For that, we can…
Hello guys, welcome back. In this tutorial, we are going to learn how to fetch data from Firebase to Nodemcu. Also, an LED ON and OFF example is used to explain…