A reed switch is a small device that when the device is exposed to a magnetic field, the two materials inside the switch pull together and the switch closes. When the magnetic field is removed, the two materials then separate and the switch will open.
Here is a picture of the reed switch breakout we have, it was part of a sensor kit
|3||+||5 volt power|
We will basically connect this up, read the analog and digital signals and monitor using the serial monitor, we will then postion the reed switch near a magnetic source and see if the readings change.
Same as a previous example
// Arduino pin numbers
//D2 and A0 used
const int digital = 2;
const int analog = 0;
Here are the results you will see
As you can see there are two basic sets of values
1/ The reed switch open/ no magnet – 0 and 1023
2/ The reed switch closed/ magnet present – 1 and 0