In this tutorial we will make use of a library called SensorMonitor available on Github. This example builds on a previous example by adding an interrupt handler to force an immediate update of the switch state. This is useful when for example you are building an alarm system and you need to update a remote system that there was entry or movement. Without having the interrupt in place and your poll time was too long, you might have missed the switching event. For example an intruder could have quickly opened and closed the door, and you might have missed that event if the next polling would have only happened in – let’s say – 1 minute.
Nothing special required besides the required components.
The source code for this project is available on my GitHub Repository.
- Push button
- 1K Resistor
- A breadboard might be useful if you don’t want to solder
Running the code
git pull https://github.com/trojanc/learn-arduino cd learn-arduino/sensor-monitor-switch-interrupt platformio init platformio run --target run platformio device monitor