Defensive code
The heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.
Open it in the simulatorWrite firmware for a heater the way safety engineers do: failure modes, defensive input, the real watchdog, asserts that stay, redundancy and reviews, all on an Uno.
0 of 7 done
7 lessons in 4 chapters, about 5 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.
The heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.
Open it in the simulatorA SAFE_ASSERT macro that never compiles away: on a broken invariant it cuts the heater, records the line number in EEPROM, resets through the watchdog and stays latched until a person presses RESET.
Open it in the simulatorA heater controller with three planted bugs, found the way a reviewer finds them: a stray semicolon that trips at room temperature, a 16-bit int that makes the dry-fire cutout impossible, and a wait loop with no way out.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
What can break, how bad it is, and code that refuses to believe bad input.
A naive thermostat that trusts every reading, and an FMEA table that ranks what can go wrong by severity, occurrence and detection. Break the sensor wire and watch it heat a tank it thinks is colder than space.
0 of 7 steps
The heater takes its setpoint over serial and trusts none of it: a line buffer that cannot overflow, strtol with an end pointer, a range check before the cast, and a clear REJECTED for everything else.
0 of 7 steps
The chip's watchdog for hangs, and asserts that fail safe in the field.
The ATmega328P's real watchdog at 250 ms: a hang it catches, a slow job that trips it, the reset cause in MCUSR, and a bad setting that hangs every boot until a counter in EEPROM drops it into safe mode.
0 of 7 steps
A SAFE_ASSERT macro that never compiles away: on a broken invariant it cuts the heater, records the line number in EEPROM, resets through the watchdog and stays latched until a person presses RESET.
0 of 7 steps
Two sensors, a setpoint stored twice, and a review that finds three bugs.
Two DS18B20s watch one tank and must agree within 2 C, the hotter one wins, and the setpoint is stored twice, once inverted, so a flipped bit in RAM is caught before it is used.
0 of 7 steps
A heater controller with three planted bugs, found the way a reviewer finds them: a stray semicolon that trips at room temperature, a 16-bit int that makes the dry-fire cutout impossible, and a wait loop with no way out.
0 of 6 steps
One controller with every layer, attacked until it gives.
Every layer in one controller: a sensor plausibility check, a latched over-temperature trip only a person can reset, a guarded setpoint, SAFE_ASSERT and the real watchdog. Attack it, then find the one failure mode it still misses.
0 of 8 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Software that must not fail are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Defensive code, Asserts in production and Reviews.
With "Failure modes", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.