The Switch
The Reed Switch sensor detects magnetic fields using two magnetic rods. When the two rods are in a magnetic field, the two rods connect and complete the electrical circuit. Also, the switch will have a sensor dead zone if orientated in a specific way. If the direction of the poles of the magnet is perpendicular to the reed switch, the sensor has a dead zone in the center of the switch.
The reed switch has 4 pins: analog output, ground, power line, and digital output. The power line takes voltages between 3.3v to 5v and the digital output returns a 1 or a 0 if it’s closed or opened. The module also has a potentiometer meant to adjust the sensitivity of the sensor, but I have worked with it and found no difference in the sensitivity of the sensor.
My uSage
I made a device that counts the number of times the wheel makes a quarter of a full rotation. By putting magnets on the wheel, the reed switch can sense when a magnet passes by it at high speeds. But to make this function as intended, I had to work through 2 issues. The first issue is that the sensor does not know when it has been reading the same magnet. If the code did not differentiate a signal that has opened and then closed, it would continuously increment the counter if the magnet was resting on the sensor. So, in the code, I kept track of when the sensor was last opened and closed. The second issue was the dead zone. The dead zone essentially makes the sensor detect a magnet twice when it passes the sensor because the dead zone interrupts the sensing, making it detect the magnet in its left sensing zone and detect it again in the right sensing zone. To fix this, I simply divided the count in half when displaying it on the LCD.
Using this setup, you can turn the device into an odometer or a speedometer by manipulating the counter variable. By multiplying the counter by the distance between each magnet, you get the distance traveled by the wheel. And if you use that same formula but reset the value each second, you get a rough way of knowing how fast the wheel moves in a second.
Leave a Reply