The reed switch is an electromagnetic switch operated by an applied magnetic field. It consists of a pair of ferromagnetic flexible metal reeds contacts in a sealed glass envelope, which become magnetized and move together (or separate) when a magnetic field is moved towards the switch. This is commonly used as proximity sensor. In order to magnetized the reed switch sensor by the magnet, the magnet should be placed parallel to the reed sensor. It means that the North and South pole of the magnet should be placed closer to the reed sensor. The module has both digital and analog outputs, normally open reed switch, resistors, leds, and has trimmer potentiometer to calibrate the sensitivity of the reed switch sensor.
Code example for Reed Switch Module
Upload the code to Arduino. Test the reed switch module by using the magnet to the reed switch. You should see the LED light turns on when you move the magnet closer to the reed switch, and the light turns off when you move the magnet away from the reed switch.