How To Connect The Module With A Reed Switch To Arduino | Hi-Tech

 

 

Hi-Tech

How to connect the module with a reed switch to Arduino

Name "reed" It is derived from the phrase "sealing contact". And this explains his device. In fact, the reed - two open (or closed) contact located in the vacuum flask, which change their state to the opposite when exposed to a magnetic field. Reed - very popular sensors that are used in many applications. This control of the opening / closing doors, a variety of counter operations, speed counters, etc. Let's connect the reed switch to Arduino and see how it works.

How to connect the module with a reed switch to Arduino

You will need:

- Arduino; - Module with Reed switch or just reed; - permanent magnet; - a computer.

Instruction how to connect the unit to the reed to arduino

Step 1:

Module is connected to the reed to the Arduino on the reduced scheme. Power is supplied by 5 V or 3.3 V. The signal connected to a digital pin of D2. Reed switch module comprises a variable resistor of 10 ohms. This resistor can be set reed switch threshold and thus adjust the sensitivity. The module also includes a LM393 comparator to eliminate false positives magnetic sensor.

The circuit module connected to the reed switch to Arduino

Step 2:

We write the sketch reed processing operation. Everything is simple. Asking pin number to which the plug-in output - "2", And turn it on "wiretap". Activate the pull-up resistor on the leg "2". Asking 13 pin as an output. Turning to the work of a serial port at 9600 baud. And then every 20 ms reads the reed and give out the value of the port. If the reed switch is open - output "1"If closed - is displayed "0". In addition, the LED on the 13th leg Arduino lit until the reed switch contacts are closed. Note the inversion of the signal read from the sensor.

Sketch for the processing operation of the reed switch

Step 3:

Connect the power to the Arduino. The module LED will light up, signaling the presence of the power module. Now podnesёm to the permanent magnet reed - reed contacts are closed and the LED lights up, showing the operation of the reed switch. Again uberёm magnet - razomknёtsya reed switch, and the LED goes out. If we include the port monitor, we see the operation of the reed switch in the form of zeros among the flow units when the contact is open.

Tripping reed

Step 4:

Let's connect a separate reed switch to Arduino. It's all very simple. The reed switch is connected similarly to the connection button with a resistor of 10 ohms. The program will remain the same. Turn the power on, hold a magnet to the reed - Arduino LED will light up until the reed switch contacts are closed.

Wiring reed switch to Arduino