Fridge Door Left Open? Build a 20-Second Arduino Alarm
A door switch gives an Arduino a simple timing problem. The alarm sounds only when the fridge door stays open for 20 continuous seconds.
The key idea
Opening the door starts the timer. Closing it clears the elapsed time, so two short visits to the fridge count as separate events.
What to remember
- Time one uninterrupted opening.
- Clear the timer when the door closes.
Check your understanding
The door opens for 12 seconds, closes, then opens for another 12 seconds. Should the alarm sound?
Show the explanation
No. Each opening lasted less than 20 seconds.