Mini magnetic reed modules 3-5.5V for Arduino COM54 ,R26

Fr3,500

This is a Mini magnetic reed modules, this module is ideally suited to adding a magnetic switch to your project

it is used in to switchboard, duplicator, washing machine, refrigerator, camera, electronic scale, gas meter and water meter, etc

In stock

SKU: SEN7133 Category:

Description

Size: Approx. 26 x 15 x 16mm/0.98 x 0.6 x 0.62inch

Working distance: 1.5 M

Operating voltage: 3.3 V-5 V

Output Type: Digital switching output (0 and 1)

Getting started with Mini magnetic reed modules 3-5.5V for Arduino

For today’s tutorial, we will demonstrate how the Mini magnetic reed modules works by connecting it alongside a LED to an Arduino. The Arduino will be programmed such that when a magnet is brought close to the Mini magnetic reed modules, the LED comes on and when the magnet is removed, it goes off.

Parts required

Connecting the Hardware

The connections for the Mini magnetic reed modules are very easier. First connect the +5 v and ground pin of the sensor to the +5v and ground pin of the Arduino. Then connect the digital pin of the sensor to the pin 2 of the Arduino.  We will use the pin 13 of the Arduino as the output pin which has a built in led attached to it on the Arduino board. So, whenever the magnet will be placed near the sensor, the module will detect the magnet and will turn on the led which is at the pin 13 of the Arduino.

CODE

The following sketch will turn on the pin 13 LED on the Arduino when the module detects a magnetic field. Place a magnet near the Mini magnetic reed modules  to activate the reel switch.

int led = 13; // LED pin
int reelSwitch = 2; // magnetic senso rpin
int switchState; // variable to store reel switch value

void setup()
{
pinMode (led, OUTPUT);
pinMode (reelSwitch, INPUT);
}

void loop()
{
switchState = digitalRead(reelSwitch); // read the value of digital interface 2 and assign it to switchState

if (switchState == LOW) // when the magnetic sensor detect a signal, LED is flashing
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
}

Copy the code and Upload to Your Arduino board. You should see the LED switch when a Magnet is brought close to it.