Source: https://mokxi.com/teachers/plans/firmware-architecture
Updated: 2026-11-11

Lesson plan

# 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.

4 chapters, 7 lessons, about 7 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## 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.

Chapter 1. About 2 h

## Structure

A superloop, a scheduler, a machine in a table, and ISRs that only record.

Lesson | Time | What students do

Superloops and state machines A 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

- Run it: five tasks, one loop
- A task is a period and a deadline
- Measure the loop
- Drive the machine
- Events from anywhere
- Break the rule
- Change behavior by changing data

Interrupts and buffers An 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

- Run it: the ISR is armed
- One press, through both halves
- Count the bounce
- volatile, and reads that cannot tear
- Fall behind
- Read the damage
- Size the ring for the burst

### 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".

Chapter 2. About 2 h

## Layers

Drivers behind interfaces, and settings that survive a reset.

Lesson | Time | What students do

Drivers and hardware abstraction A 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

- Run it: three layers
- The driver keeps the data sheet's promises
- Heat the room
- Swap in a fake
- Kill the sensor on demand
- What an interface costs
- Boot on the fake

Configuration and EEPROM Settings 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

- Run it: a blank chip
- Change a setting
- Write only what changed
- Reset, and it is still there
- Flip one bit
- A CRC checks bytes, not sense
- Ship a new default

### 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".

Chapter 3. About 2 h

## Survive the field

Error codes, fail-safe states, the watchdog, and updates that cannot brick.

Lesson | Time | What students do

Error handling and watchdogs A 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

- Run it: a heater with a guard dog
- Error codes, not made-up numbers
- Retries run out: fail safe
- A person clears the fault
- Hang it: the watchdog bites
- Stall it: check-ins catch what feeding misses
- Some errors trip at once

OTA and bootloader concepts How 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

- Run it: two slots, one decision
- Why two slots
- The header: trust nothing you cannot check
- Trial boots and rollback
- Confirm
- Refuse a perfect old image
- Give up sooner

### 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".

Chapter 4. About 1 h 5 min

## Boss

A multi-sensor machine guard built from every layer in the course.

Lesson | Time | What students do

Boss: a layered machine guard The 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

- Run it: six layers, one device
- Ask the drivers
- Close the guard, start the spindle
- Open the guard: trip
- Clear it only when it is safe
- Warm, then too hot
- Cut the sensor wire
- Ship a cooler warning

### 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".

Your class

## 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.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
