The Reed Switch is a simple yet powerful magnetic sensor widely used in security systems, door sensors, smart appliances, and automation projects. In this blog, we’ll cover how to use a Reed Switch with Arduino, how it works, how to wire it, and real-world project ideas. Whether you’re making a magnetic door alarm, bike theft detector, or smart cabinet system, this guide will walk you through everything you need to know.
If you noticed that when we are turn the screen on and off the laptop will automatically shut down and starts. How it is possible. Here we are using reed switches. These switches are cheap and reliable. These are very easy to use. These switches turn on and off when there is any magnet nearby.

What is a Reed Switch?
A Reed Switch is a type of magnetic proximity sensor. It consists of two thin metal blades (ferromagnetic contacts) sealed inside a glass tube. When a magnet comes near the sensor, the blades are pulled together, closing the circuit.
No magnet = open circuit
Magnet near = closed circuit
Reed switches are digital sensors, meaning they only detect two states: ON or OFF.
How Does Reed Switch Work?
It works on the principle of magnetic field. When you bring the magnet close to the switch then switch becomes the part of the circuit include magnets.
When you bring the magnet close to the switch the plates gives contact to each other as a result the current flows. When you bring magnet away from the switch the plates move far from each other. Now current cannot flow through them.
- When a magnet approaches, the magnetic field causes the two blades to attract and touch, allowing current to pass.
- When the magnet is removed, the blades separate, and the circuit is broken.
There are two types of reed switches:
- Normally Open (NO): Open by default, closes when a magnet is near.
- Normally Closed (NC): Closed by default, opens when a magnet is near (less common in hobby electronics).
Reed Switch Overview:
A reed switch consists of pair of magnetic plates or reeds made of ferromagnetic material. The surface of reeds are coated with some type of material such as palladium etc. which gives life to the switch as they open and close for millions of times. These reeds are then enclosed in the glass capsule to prevent them from dust and air.

Components required for using Reed Switch with Arduino?
Component | Quantity |
---|---|
Arduino Uno (or Nano) | 1 |
Reed Switch Sensor | 1 |
Magnet (Neodymium preferred) | 1 |
10K Resistor (Pull-up) | 1 |
LED or Buzzer (optional) | 1 |
Breadboard & Wires | As needed |
Circuit Diagram of Reed Switch with Arduino:
The connection of reed switch is very simple. First of all you have to inset reed switch in the breadboard and using jumper connect one wire with Arduino GND and the other goes to any digital pin of Arduino.
Here’s how to wire a Normally Open (NO) reed switch
Reed Switch Pin | Connects To |
---|---|
One end | GND |
Other end | Digital Pin (e.g., D2) |

Code for using Reed Switch with Arduino:
const int REED_PIN = 2; // Pin connected to reed switch
const int LED_PIN = 13; // LED pin
void setup() {
Serial.begin(9600);
pinMode(REED_PIN, INPUT_PULLUP); // Enable internal pull-up for the reed switch
pinMode(LED_PIN, OUTPUT);
}
void loop() {
int proximity = digitalRead(REED_PIN); // Read the state of the switch
// If the pin reads low, the switch is closed.
if (proximity == LOW) {
Serial.println("Switch closed");
digitalWrite(LED_PIN, HIGH); // Turn the LED on
}
else {
Serial.println("Switch opened");
digitalWrite(LED_PIN, LOW); // Turn the LED off
}
}

Applications of Reed Switch:
- Door/window intrusion sensors
- Smart cabinet open/close detection
- Bike lock detection systems
- Robot movement or wheel position tracking
Troubleshooting of Reed Switch with Arduino:
If your reed switch project isn’t working, try the following:
1. Switch Not Responding to Magnet
- Check polarity: Some reed switches are polarity-sensitive if embedded in modules.
- Use a stronger magnet: Neodymium magnets work best.
- Try changing magnet position: It may need to align directly with the switch.
2. Constant HIGH or LOW Reading
- Check pull-up resistor: Ensure the 10K pull-up resistor is connected correctly to 5V.
- Switch contacts stuck: Gently tap the switch or try a different one.
- Incorrect pin mode: Verify
pinMode(reedSwitch, INPUT);
is set in the code.
3. Serial Monitor Not Showing Messages
- Make sure you’ve added
Serial.begin(9600);
insetup()
. - Use the correct baud rate in the Serial Monitor (9600).
- Confirm the right COM port and board are selected in the Arduino IDE.
4. Random or Unstable Readings
- Use debouncing (add a small delay in code) to avoid false triggering.
- Ensure wires and switch contacts are firmly connected.
- Try using INPUT_PULLUP mode in code and connect the switch directly to GND:
Conclusion
Using a Reed Switch with Arduino is a great way to add magnetic proximity sensing to your DIY electronics projects. Simple wiring, minimal code, and versatile applications make this sensor ideal for both beginners and pros.
Need Help in Setup of Reed Switch with Arduino?
If you need any Help or Assistance for Setup of Reed Switch with Arduino, with Modifications or Customization then you can contact us through WhatsApp. We can deliver you this Project in the Following Ways.