ARDUINO REED SWITCH Tutorial – How to use Arduino REED SWITCH

 Arduino REED Switch Tutorial

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.

(adsbygoogle = window.adsbygoogle || []).push({});

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.

ARDUINO REED SWITCH Tutorial
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.

ARDUINO REED SWITCH Tutorial
(adsbygoogle = window.adsbygoogle || []).push({});
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.
ARDUINO REED SWITCH Tutorial
  • 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.
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
OK, Let’s do this project step by step.

Step 1

Identify these components.
Arduino UNO board.
 
Reed switch sensor.
LED bulb.
180ohm Resistor.
Breadboard.
Jumper wires.

Step 2

Connect these components using the circuit diagram below.
ARDUINO REED SWITCH Tutorial
(adsbygoogle = window.adsbygoogle || []).push({});

Step 3

Now, we will create the necessary program for this. It is as follows.
The complete program of this project – Download
/*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.
ARDUINO REED SWITCH Tutorial
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.

ARDUINO REED SWITCH Tutorial – How to use Arduino REED SWITCH

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *