How to Use a Magnetic Reed Switch with Arduino

Introduction

In this blog post, we will explore How to Use a Magnetic Reed Switch with Arduino. We will discuss what a magnetic reed switch is, how it works, and A magnetic reed is an electromechanical device that behaves like a switch that is activated by the presence of a magnet. Magnetic reed sensors are widely used. For example, many door and window alarms work by placing a magnet on the element, and detecting the opening with a magnetic reed. We can also place the magnet on a door, or display case, to turn on a light, etc

Hardware Required

You will require the following Hardware Components for interfacing Magnetic Reed Switch with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Link
Magnetic Reed Switch1Buy Link
LED 5mm1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires2Buy Link
Breadboard1Buy Link

What is a Magnetic Reed Switch?

A magnetic reed switch is a type of electrical switch that is activated by a magnetic field. It consists of two metal contacts, usually made of ferromagnetic materials, enclosed in a glass tube. The contacts are normally open, but when a magnetic field is applied, they come into contact and complete the circuit.

How Does a Magnetic Reed Switch Work?

When a magnetic field is present near the reed switch, the contacts inside the glass tube are attracted to each other, closing the circuit. This allows current to flow through the switch. When the magnetic field is removed, the contacts separate, opening the circuit and stopping the current flow.

Magnetic-Reed-Switch-working

Magnetic reed switches are highly sensitive and can be activated by a variety of magnetic sources, including magnets, electromagnets, or even the Earth’s magnetic field.

Circuit Diagram

The following circuit shows you the connection of the How to Use a Magnetic Reed Switch with Arduino Please make the connection carefully

How-to-Use-a-Magnetic-Reed-Switch-with-Arduino-Circuit-diagram

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code

The following code provide a simple example. We use a digital input, with the internal pull-up resistor, to find the state of the magnetic reed. If the sensor is activated, the input will read LOW, and in that case we turn on the LED integrated on the board. Of course, in a real project, instead of turning on the integrated LED we would execute the actions we wanted.

//For more Projects: www.arduinocircuit.com

const int pinSensor = 2;
const int pinLED = 13;

void setup() {
  //configure pin as input with internal pull-up resistor
  pinMode(pinSensor, INPUT_PULLUP);
  pinMode(pinLED, OUTPUT);
}

void loop() {
  int value = digitalRead(pinSensor);

  if (value == LOW) {
    digitalWrite(pinLED, HIGH);
  } else {
    digitalWrite(pinLED, LOW);
  }

  delay(1000);
}

Applications

  1. Security Systems: Magnetic reed switches are commonly used in security systems to detect the opening and closing of doors and windows. When a door or window is opened, the magnetic field is disrupted, triggering an alarm.
  2. Proximity Sensors: Magnetic reed switches can be used as proximity sensors to detect the presence or absence of a magnetic object. This can be useful in applications such as detecting the position of a door or the level of liquid in a tank.
  3. Automotive Applications: Magnetic reed switches are used in automotive applications, such as detecting the position of the gear shift lever or the presence of a key in the ignition. They are also used in anti-theft systems to detect unauthorized entry.

Leave a Comment


error: