Interfacing sensors
In this section, we are going to discuss interfacing sensors on the Pico, in particular, a reed switch. We picked a reed switch because we have all been in situations where we either cannot hear a door open, or you are not aware when someone doesn't close a door properly. We are going to discuss detecting such situations using a reed switch.
A reed switch is a type of switch that closes and makes contact in the presence of a magnetic field. Figure 3.1 shows a reed switch sold by Adafruit that could be used as a door sensor. The sensor consists of two pieces, namely, the magnet and the reed switch.
The magnet is usually installed on the door while the reed switch is installed on the door frame. When the magnet is within 13 mm of the reed switch, the switch is closed. We are going to make use of this principle to detect the door state.
The steps to interface a door sensor with the Pico include the...