Source: https://mokxi.com/teachers/plans/software-design-testing
Updated: 2026-11-11

Lesson plan

# Software design and testing lesson plan

How teams keep firmware right as it grows: readable code, modules behind narrow interfaces, fakes, tests on boot, test-first fixes, safe refactors and code review. Ends with a messy sketch refactored under test.

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

- Names, one job per function, and modules behind a narrow interface.
- A harness in twenty lines, then bugs fixed test first.
- Refactors under test, and the review and git habits of a team.
- A messy dice sketch, fixed test first and refactored under its own self-test.

### Materials for the whole unit

- Arduino Uno R3
- Fan module, L9110
- Full-size breadboard
- Half breadboard
- LED x 3
- Pushbutton
- Resistor x 3
- Seven segment display
- Temperature sensor

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 1 h 55 min

## Code people can read

Names, one job per function, and modules behind a narrow interface.

Lesson | Time | What students do

Clean functions and naming A thermostat sketch that works and lies: one-letter names, magic numbers that drifted apart, one loop doing four jobs. Name the numbers, give each job a function, and read loop() like a table of contents. | 60 min

- Run it: a sketch only its author can read
- Heat it up: the sketch lies
- Name the number
- One job, one function: the report
- Name the timing, and give the heartbeat a function
- Names that say what
- loop() as a table of contents

Modules and interfaces A thermostat that only knows a TempSensor interface: a real TMP36 and a fake behind the same door, a rehearsal with the fake on boot, a move into sensor.h, and a calibration added without touching the thermostat. | 55 min

- Run it: a rehearsal before the real thing
- The interface is one question
- Hysteresis, tested where it is hard
- Swap the sensor, not the thermostat
- Give the sensors their own file
- A third sensor, and no change to the thermostat

### Materials

- Arduino Uno R3
- Fan module, L9110
- Half breadboard
- Temperature sensor

### Check for understanding

Each student finishes "Modules and interfaces" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A third sensor, and no change to the thermostat".

Chapter 2. About 2 h

## Tests that run themselves

A harness in twenty lines, then bugs fixed test first.

Lesson | Time | What students do

Unit tests with plain asserts A test harness in twenty lines: a CHECK macro that prints PASS or FAIL with the line and the condition, a summary line and a red or green lamp. Test the edges, meet a real failure, fix it, and switch the tests off for a release. | 60 min

- Run it: eight checks before loop()
- How a CHECK line knows what it checked
- Green means all of them
- Test the edges
- A test that finds a real bug
- Fix it, and watch it go green
- Tests out of the release

Test-driven fixes A bug report against a countdown that passes all its tests: reproduce it on the hardware, pin it to one pure function, write the test that fails, fix it, triangulate the edges, and close the report. | 60 min

- Run it: green, and still wrong
- Reproduce it on the hardware
- Pin it to one function
- Red: the test that fails
- Green: the fix
- Triangulate the edges
- Close the report

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Test-driven fixes" 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: "Close the report".

Chapter 3. About 1 h 55 min

## Changing code safely

Refactors under test, and the review and git habits of a team.

Lesson | Time | What students do

Refactoring A Beaufort wind scale as an if chain and a switch, reshaped into two tables with its tests green after every step: replace a conditional with a table, prove the net catches a slip, extract a function, and add a feature in one line. | 60 min

- Run it: a safety net first
- What it does today
- Replace the conditional with a table
- Slip on purpose
- Extract a function, so it can be tested
- Now a feature is two numbers
- Same program, better shape

Code review and git, explained Commits, branches, diffs and pull requests explained properly, then a real review: a teammate's pull request with a millis() rollover, an off-by-one and an int overflow, each caught by a checklist question and proven fixed by the self-test. | 55 min

- Run it: a pull request lands
- Read the diff
- Comment one: time math
- Comment two: the loop bounds
- Comment three: is the type big enough?
- Your checklist, your commit

### Materials

- Arduino Uno R3
- Full-size breadboard
- LED x 3
- Pushbutton
- Resistor x 3

### Check for understanding

Each student finishes "Code review and git, explained" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your checklist, your commit".

Chapter 4. About 1 h 10 min

## Boss

A messy dice sketch, fixed test first and refactored under its own self-test.

Lesson | Time | What students do

Boss: refactor the dice, tests green The gallery's electronic dice after a game night of quick fixes: one-letter names, an if chain, pasted code and a bug report. Fix the bug test first, then refactor it clean, one step at a time, with the self-test saying all pass after every run. | 70 min

- Run it: the sketch nobody wants to touch
- Roll it
- Fix the bug, test first
- Refactor 1: names
- Refactor 2: the font as a table
- Refactor 3: one show(), not two pastes
- Leave a check behind
- Finish it your way

### Materials

- Arduino Uno R3
- Full-size breadboard
- Pushbutton
- Resistor
- Seven segment display

### Check for understanding

Each student finishes "Boss: refactor the dice, tests green" 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: "Finish it your way".

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.
