Firmware architecture lesson plan
How a whole device is put together on the Uno: a scheduler and state machines, ISRs that only record, drivers behind interfaces, checked settings in EEPROM, error codes and the watchdog, safe updates, and a layered multi-sensor boss.
Objectives and materials
By the end, students can
- A superloop, a scheduler, a machine in a table, and ISRs that only record.
- Drivers behind interfaces, and settings that survive a reset.
- Error codes, fail-safe states, the watchdog, and updates that cannot brick.
- A multi-sensor machine guard built from every layer in the course.
Materials for the whole unit
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Half breadboard
- Hall sensor, A3144
- LED x 3
- Photo interrupter, slot
- Pushbutton
- Resistor x 3
- Temperature and humidity, DHT22
- Temperature sensor, LM35
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
Structure
A superloop, a scheduler, a machine in a table, and ISRs that only record.
| Lesson | Time | What students do |
|---|---|---|
| Superloops and state machinesA cooperative scheduler that runs tasks on their own periods, a state machine whose behavior lives in a transition table, and a stopwatch on every pass of loop() that catches a task breaking the one rule. | 60 min |
|
| Interrupts and buffersAn ISR that only records each edge and its time into a ring, a main loop that drains and debounces it, volatile and atomic reads done right, and an overflow counter that tells you when the loop fell behind. | 60 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "Interrupts and buffers" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Size the ring for the burst".
Layers
Drivers behind interfaces, and settings that survive a reset.
| Lesson | Time | What students do |
|---|---|---|
| Drivers and hardware abstractionA comfort monitor that only talks to a ClimateSensor and a Display interface: a DHT22 driver, an LCD driver, and a scripted fake that plays a heat wave, a dry room and a dead sensor on demand. | 60 min |
|
| Configuration and EEPROMSettings in an envelope: a magic number, a version, a size and a CRC-16, checked field by field at every boot, defaults when anything is off, only changed bytes written, and a watchdog reset to prove it all survives. | 60 min |
|
Materials
- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Half breadboard
- LED x 3
- Pushbutton
- Resistor x 3
- Temperature and humidity, DHT22
Check for understanding
Each student finishes "Configuration and EEPROM" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Ship a new default".
Survive the field
Error codes, fail-safe states, the watchdog, and updates that cannot brick.
| Lesson | Time | What students do |
|---|---|---|
| Error handling and watchdogsA heater controller whose functions return error codes, a policy table that retries or trips a latched fail-safe, and the chip's real watchdog in its two-stage mode: task check-ins, last words saved to EEPROM, then a reset. | 60 min |
|
| OTA and bootloader conceptsHow a device updates itself without ever bricking: A/B slots, an image header with a version, a length and a CRC-32, trial boots that must confirm, automatic rollback, and a minimum version that refuses a perfect copy of old firmware. | 60 min |
|
Materials
- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3
Check for understanding
Each student finishes "OTA and bootloader concepts" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Give up sooner".
Boss
A multi-sensor machine guard built from every layer in the course.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a layered machine guardThe sensor lab becomes a real device: drivers for an LM35, a Hall switch and a slotted wheel, a scheduler with check-ins, a table-driven machine, checked thresholds in EEPROM, error codes and a latched trip. | 65 min |
|
Materials
- Arduino Uno R3
- Hall sensor, A3144
- Photo interrupter, slot
- Temperature sensor, LM35
Check for understanding
Each student finishes "Boss: a layered machine guard" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Ship a cooler warning".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.