0

members

Easy Basics: Project 030a Reed switch, LEDs, active piezo buzzer - magnetic field detection switch

of Lex C in UNO

Basics: Project 030a

Project name: Reed switch, LEDs, active piezo buzzer - magnetic field detection switch

Attachments: sketch1, doorsketch

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Arduino IDE ( you can download it from here  )

3.Jumper cables

4. Breadboard

5. Reed switch 1 pc

6. LED 2 pcs (red and green color)

7. Resistor 2 pcs (220 Ohm each)

8. Active pize buzzer 1 pc

General

We will learn how to connect reed switch, active piezo buzzer and LEDs to Arduino board.

Understanding the piezo buzzer

You can read more about it here.

Understanding the reed switch

The reed switch (sometimes also known as Herkon) is an electrical switch operated by an applied magnetic field. It was invented at Bell Telephone Laboratories in 1936 by W. B. Ellwood. It consists of a pair of contacts on ferromagnetic metal reeds in a hermetically sealed glass envelope. The contacts may be normally open, closing when a magnetic field is present, or normally closed and opening when a magnetic field is applied. The switch may be actuated by a coil, making a reed relay, or by bringing a magnet near to the switch. Once the magnet is pulled away from the switch, the reed switch will go back to its original position.

One of examples of a reed switch's application is to detect the opening of a door, when used as a proximity switch for a burglar alarm. Another - some flip-style cellphones are switched on and off by magnetic reed switches. There's a magnet in one part of the case and a reed switch in the other. 

A magnetic contact switch is basically a reed switch encased in a plastic shell so that you can easily apply them in a door, a window or a drawer to detect if the door is open or closed.
The switch that we are going to use has two parts: the switch itself, that usually comes opened, and the magnet. When you buy this switch, it also comes with 4 screws, so that you can attach it to your door.

A magnetic contact switch is basically a reed switch encased in a plastic shell so that you can easily apply them in a door, a window or a drawer to detect if the door is open or closed. The switch that you can use to monitor your door status has two parts: the switch itself, that usually comes opened, and the magnet. When you buy this switch, it also comes with 4 screws, so that you can attach it to your door.

How does a reed switch work?

Reed switches come in two main varieties called normally open (normally switched off) and normally closed (normally switched on). The key to understanding how they work is to realize that they don't just work as an electrical bridge but as a magnetic one as well: magnetism flows through them as well as electricity.

Normally open

A normally open reed switch opens and closes when a magnet approaches or moves away.

As you bring a magnet up to the reed switch, the entire switch effectively becomes a part of a "magnetic circuit" that includes the magnet (the dotted line in the artwork shows part of the magnetic field). The two contacts of the reed switch become opposite magnetic poles, which is why they attract and snap together. It doesn't matter which end of the magnet approaches first: the contacts still polarize in opposite ways and attract one another. A reed switch like this is normally open (NO) (normally off), unless a magnet is positioned right next to it, when it switches on, allowing a current to flow through it.

Take the magnet away and the contacts - made from fairly stiff and springy metal - push apart again and return back to their original positions.

Normally closed

A normally closed reed switch opens and closes when a magnet approaches or moves away.

You can also get reed switches that work the opposite way: the two contacts are normally snapped together and when you bring a magnet up to the switch, spring apart. Reed switches like this are called normally closed (NC) (normally switched on), so electricity flows through them most of the time. The easiest way of making one is to take a normally open switch and fix a magnet permanently to its glass case, flipping it over from its open to its closed state (as in the second frame in the normally open animation up above). This entire unit (normally open reed switch with magnet attached) becomes our normally closed reed switch. If you bring a second magnet up to it, with a magnetic field of opposite polarity to that of the first magnet, this new field cancels out the field of the first magnet so we have, in effect, exactly what we had in the first frame of the normally open animation: a reed switch with two contacts sprung apart.

Real reed switches have contacts that are only a few microns (millionths of a meter) apart - roughly ten times thinner than a human hair - so the movement isn't visible to the naked eye. Don't expect to see the blades moving as you bring your magnet up close!

See the specification of reed switch here.

Signals and connections of the reed switch

GND - connects to ground

SIG or D0 - digital output (0 or 1) connects to digital pin of Arduino board

VCC - connects to DC +5V supply

Signals and connections of LED

The operating voltage of the LED is 1.8V and the operating current is 10mA-20mA. The Arduino Uno board can supply 5V or 3.3V power. We will use 5V for this project, so the minimum resistance of the current limiting resistor should be (5 V to 1.8 V)/20 = 160 Om. The 220 Om offered in the kit is suitable and you can also choose other resistors that meet the condition. The larger the resistance is, the dimmer the LED will get.

Signals and connections of piezo buzzer

Piezo buzzer pin marked with (+) sign should be connected to Arduino Uno board digital pin which sends a signal, the other pin of active piezo buzzer should be connected to Arduino Uno board GND. If you use resistor for piezo buzzer connect it between piezo pin marked (+) sign and Arduino Uno digital pin.

Build the circuit

The following picture shows the needed connections with the Arduino Uno 

Step by Step instruction

  1. Open Arduino IDE.
  2. Plug your Adruino Uno board into your PC and select the correct board and com port
  3. Open up serial monitor and set your baud to 9600 baud
  4. Verify and upload the the sketch to your Adruino Uno board.
  5. Use a permanent magnet close to the reed switch module, and the LED on the reed switch module and the red LED on the Arduino Uno board light up nad the buzzer will start to sound (green LED will be off). Move the magnet farther and the red LED on Arduino board and reed switch module, buzzer will go out (green LED will be on).
  6. You can also use the doorsketch to monitor the status of yor door. The red LED will turn on if your door is open and a green LED if your door is closed.

Summary

We have learnt how to connect reed switch, active piezo buzzer and LEDs to Arduino board.

Library:

  • No libraries required for this project

Sketch:

  • See attachments on the begining of this project description. 


Other projects of Lex C
Easy Basics: Project 057a ACR122U NFC Reader of Lex C, Not selected 17-01-2018

Published at 14-09-2017
Viewed: 1677 times