Session 47: Extension workshop: interrupts and the clock alarm
Learning outcomes
- Use an external interrupt on D2 with a volatile flag
- Explain what may and may not happen inside an ISR
- Combine the RTC, LCD, servo and buzzer in the clock alarm state machine
Kit and components
- Uno, push button, LED, passive buzzer
- For the clock alarm: RTC, I2C LCD, servo and separate supply
Pre-reading about 20 min
Students read these on their phones before class. They are listed on the student Before class page.
Session plan
- 0:0010 minRecap
Task C reflections
- 0:1025 minDemo
Interrupts in one rule
Set a flag in the ISR and do the work in loop(). Show what goes wrong when Serial is called inside an ISR.
- 0:3530 minBuild
Interrupt worked sketch
Students build the worked sketch and add the lesson challenge: ignore further interrupts for 200 ms.
- 1:0545 minBuild
Clock alarm capstone or Task C extension
Students whose final project needs an alarm or scheduling build the clock alarm capstone; others extend their Task C controller.
- 1:5010 minWrap-up
Which technique does your project need?
Checkpoint: ready to move on?
Students can state the ISR rules and have either an interrupt sketch with a debounce window or a progressing clock alarm build.
Extension for fast finishers
Read the optional appendix templates - timer interrupt, sleep and wake - that apply to their project.
Catch-up path
Skip the capstone and complete the interrupt sketch only.
Homework and practice
Update the final project plan with any new techniques.
Facilitator notes
- Flex session: in a shorter course the extension workshops become final project research time.