Reed Switches Arduino

Reed switches are versatile components that find numerous applications in electronics, particularly when paired with Arduino. Their ability to sense magnetic fields and trigger actions makes them invaluable for various projects. In this in-depth guide, we will delve into the world of reed switches and explore their integration with Arduino, unlocking creative possibilities.

What are Reed Switches?

Reed switches are small, electromagnetic devices with two thin, magnetic, and flexible metal reeds enclosed within a glass tube. When a magnetic field is applied to the reeds, they attract, making a connection. When the magnetic field is removed, it springs back to its original position, breaking the connection. This simple yet effective mechanism allows reed switches to act as binary switches.

Reed Switches Arduino: Understanding the Synergy

Reed switches and Arduino can work in tandem to create various automation and control systems. When a magnetic field is used to actuate a reed switch, Arduino can process this change in state to initiate specific actions, making it a fundamental building block for countless projects.

Components Needed

Before diving into using reed switches with Arduino, you’ll need the following components:

Reed Switches

  • Choose the appropriate reed switch based on your project’s requirements.

Arduino Board

  • Any Arduino board can be used depending on your project’s complexity.


  • A permanent magnet to actuate the reed switch.

Resistors and LEDs (Optional)

  • Depending on your project, you might need resistors and LEDs for feedback.

Wiring Reed Switches with Arduino

Wiring reed switches to Arduino is relatively straightforward, but it’s essential to pay attention to the connections to ensure proper functionality.

Step-by-Step Guide

  1. Connect one end of the reed switch to a digital pin on the Arduino board.
  2. Connect the other end of the reed switch to the ground (GND) pin on the Arduino.
  3. Attach one terminal of the magnet to a moving part that will trigger the reed switch.
  4. Position the reed switch near the magnet so that the magnet activates the switch when it’s in proximity.

Programming Reed Switches Arduino

Once the hardware is set up, it’s time to program your Arduino to make the most of your reed switch. Here’s a simple example of code to get you started:

The code

int reedSwitchPin = 2; // Define the digital pin connected to the reed switch

int ledPin = 13; // Define the built-in LED pin on the Arduino board


void setup() {

  pinMode(reedSwitchPin, INPUT); // Set the reed switch pin as an input

  pinMode(ledPin, OUTPUT); // Set the LED pin as an output



void loop() {

  int reedSwitchState = digitalRead(reedSwitchPin); // Read the state of the reed switch


  if (reedSwitchState == HIGH) {

    digitalWrite(ledPin, HIGH); // Turn on the LED when the reed switch is activated

  } else {

    digitalWrite(ledPin, LOW); // Turn off the LED when the reed switch is deactivated




This code will turn on an LED on your Arduino board when the magnet activates the reed switch and turn it off when the magnet is removed.

Expanding Your Reed Switch and Arduino Knowledge

Advanced Projects and Ideas

Once you’ve mastered the basics of reed switches and Arduino, you can venture into more advanced projects. Here are a few ideas to spark your creativity:

Smart Lock System

Build a smart lock system for your home using reed switches to detect the position of the door and control access with an Arduino-based keypad or smartphone app.

Weather Station

Create a DIY weather station with reed switches to measure wind speed, rainfall, and temperature, transmitting the data to your computer or a cloud service for analysis.

Automated Plant Watering System

Design an automated plant watering system that senses soil moisture with a reed switch and dispenses water as needed, ensuring your plants always receive the right amount of hydration.

Magnetic Levitation

Explore the principles of magnetic levitation by using reed switches to control the magnetic field and stabilize the levitating object. This project combines science and aesthetics.

Troubleshooting Tips

As you experiment with reed switches  Arduino, you may encounter challenges. Here are some common troubleshooting tips:

  • Check the Connections: Ensure all your connections are secure and correctly wired.
  • Magnet Placement: Verify that the magnet activates the reed switch when it’s in proximity. Adjust the magnet’s placement if necessary.
  • Code Issues: Review your Arduino code for errors and ensure it matches your hardware setup.
  • Power Supply: Ensure your Arduino board is receiving adequate power.
  • Reed Switch Quality: Low-quality reed switches may need to be more reliable. Consider investing in high-quality components for critical projects.

Stay Updated and Share Your Knowledge

The world of electronics and Arduino is constantly evolving. To stay updated with the latest developments, consider joining online forums communities and participating in maker events.

Sharing your knowledge and experiences can be equally rewarding, as it contributes to the collective wisdom of the Arduino community.

In conclusion, reed switches  Arduino offer an exciting combination of simplicity and versatility, making them valuable tools for countless projects.

From enhancing home security to automating everyday tasks, these components provide endless opportunities for innovation. With this comprehensive guide, you’re well-equipped to embark on your reed switch and Arduino journey.

So, what’s your next project going to be?

Remember, the only limit is your creativity, and the world of reed switches and Arduino is waiting for you to explore its boundless potential. Happy tinkering!

Resources for Further Learning

If you’re hungry for more knowledge on reed switches and Arduino, there’s a wealth of resources available to help you on your journey:

Online Tutorials

Search for online tutorials and video guides that cover specific projects or aspects of reed switches  Arduino. Websites like, Adafruit, and SparkFun offer tutorials to cater to all skill levels.

Arduino Communities

Join Arduino forums and communities, such as the Arduino Forum, Reddit’s r/arduino, or the Arduino Stack Exchange. Here, you can ask questions, share your projects, and learn from experienced users.

Arduino Books

Consider investing in Arduino books that delve into various topics and project ideas. Titles like “Arduino For Dummies” by John Nussey and “Arduino Cookbook” by Michael Margolis are excellent starting points.

YouTube Channels

There are several YouTube channels dedicated to Arduino and electronics, such as “GreatScott!” and “TheArduinoGuy.” They offer step-by-step project tutorials and explanations of various components.

Local Maker Spaces

Explore local maker spaces or tech hubs in your area where you can collaborate with fellow enthusiasts, access equipment, and take part in workshops.

Online Courses

Enroll in online courses on platforms like Coursera, Udemy, and edX that provide structured learning paths and certifications in Arduino and electronics.

Experiment and Innovate

The best way to solidify your knowledge is by getting hands-on experience. Experiment with different sensors, actuators, and microcontrollers, and be bold and push the boundaries of what’s possible with reed switches  Arduino.

Keep Abreast of Arduino Updates

Arduino releases updates and new boards periodically. Stay informed about the latest developments and consider exploring these new hardware options for exciting projects.

In your quest to master reed switches and Arduino, remember that the most valuable lessons often come from your experiments and experiences.

So, feel free to take on challenging projects and share your discoveries with the Arduino community.

With a curious mind, dedication, and abundant resources, you’re well on your way to becoming an Arduino expert.

The world of reed switches  Arduino is a fascinating one, and your journey has just begun. What will you create next?

Frequently Asked Questions (FAQs) 

Q1: What are some common applications of reed switches Arduino?

A1: Reed switches with Arduino find applications in various fields, including home automation (door and window sensors), security systems, automotive (gear shift sensors), and water-level detectors.

Q2: Can I use different types of magnets with reed switches?

A2: Yes, you can use different magnets, such as neodymium, ceramic, or Alnico, depending on your project’s requirements. Experiment to find the most suitable one.

Q3: Are there different types of reed switches, and how do I choose the right one?

A3: Reed switches come in various forms, including ordinarily open (NO) and normally closed (NC). The choice depends on whether you want the switch to activate when the magnet is near (NO) or when it moves away (NC). Consider your project’s needs when selecting the type.

Q4: How can I extend the range of reed switches?

A4: You can extend the range of reed switches by using stronger magnets or by amplifying the magnetic field with the help of magnetic shields or concentrators.

Q5: Can I use reed switches to count rotations or measure distance?

A5: Yes, reed switches can count rotations by attaching them to a rotating object and positioning magnets accordingly. To measure distance, you would need a more complex setup, often involving multiple reed switches.


Incorporating reed switches into your projects alongside Arduino not only offers a window into the world of magnetism and automation but also unlocks a realm of limitless creativity.

With a solid understanding of how these simple yet powerful components work, the ability to wire and program them effectively, and a dash of inspiration, you’re poised to embark on a journey of innovation.

From enhancing your home’s security to automating everyday tasks, reed switches  Arduino empower you to bring your ideas to life.

Your imagination is the only limiting factor, and the world of reed switches and Arduino is your canvas for exploration.

As you gain experience and expertise, you can venture into more complex and exciting projects, pushing the boundaries of what’s achievable with this dynamic duo.

Whether it’s a sophisticated home automation system, a weather station that connects you to nature, or a mesmerizing magnetic levitation experiment, the possibilities are limited only by your creativity.

Remember, the journey doesn’t stop here.

There’s a vast world of resources, communities, and fellow enthusiasts waiting to support your endeavors. So, what’s your next project going to be?

The answer to that question lies within your curiosity and willingness to explore the fascinating universe of reed switches  Arduino. As you set out to create, innovate, and learn the only certainty is that your journey is just beginning, and the possibilities are endless. Happy tinkering!

Pin It on Pinterest

Share This