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.
Hello and welcome back. In this project, we will learn how to make a Bluetooth control Jeep using Arduino. For that, I have mainly used the Arduino Nano board, HC-5…
Hello guys, Welcome back to my blog. We have described INPUT and OUTPUT in previous posts. We will create projects using this knowledge. Ok, let’s go to today’s post. Today…
Hello guys, welcome back to my SriTu Hobby blog. Today we will learn about Tilt sensors. A tilt sensor can be identified as a device that detects the tilting of…
Hello guys.Welcome back to my SriTu Hobby blog. Today we will learn about piezo sensors. A Piezo sensor is a device used to measure changes in pressure, acceleration, temperature,…
Hello guys, welcome back to my SriTu Hobby blog. This tutorial includes how to make an Arduino clock. Also, we can use this Arduino LCD clock for the bedroom, study…
Hello guys, welcome back to another article from SriTu Hobby. Today we are going to talk about how to make an automatic light lamp with Arduino. Also, this project is…