Raspberry Pi Pico Door-Open Alarm | Timer, Contact & OLED
A door contact starts a timer on the Raspberry Pi Pico. The OLED can show how long the door has remained open before the alarm sounds.
The key idea
Start timing on the transition to open. If the contact still reads open on the next loop, the original start time must be preserved. Closing the door ends that open interval.
What to remember
- Time each continuous open interval.
- Show elapsed time so a user can distinguish a brief opening from a persistent one.
Check your understanding
Why would restarting the timer every time the contact reads open prevent the alarm?
Show the explanation
Each restart erases the elapsed interval, so it may never reach the alarm delay.