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.
What is the Arduino Reed switch?
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.
2.Normally closed Reed switch.
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.
http://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.
Blynk app setup Tutorial Hello guys, welcome back to another tutorial from the SriTu Hobby blog. This tutorial covers how to set up a Blynk app. Also, this…
Hello, welcome back. In this tutorial, we will learn how to make a gas leakage monitoring system using the Nodemcu board and Blynk app. This project mainly uses the MQ2…
Hello, welcome back. In this tutorial, we will learn how to make a customizable Bluetooth controller car using Arduino. Also, this Bluetooth car is different from the other Bluetooth control…
Hello friends, Welcome back to my blog. We described the LED bulb display in a previous post. It is very difficult to show what we want with this LED display….
How to use MPU6050 with Arduino Hello, welcome back. In this tutorial, I will show you how to use MPU6050 with Arduino. Through this sensor, we can measure rotation…