enum class
An airlock state machine with names that stay in their scope, never turn into an int by accident, fit in one byte, and make the compiler check every switch.
Open it in the simulatorThe parts of modern C++ that make firmware safer and cost nothing on the chip, measured on an ESP32-C3: constexpr, enum class, std::array, RAII, lambdas and templates without bloat. Ends with a zero-cost pin driver that races digitalWrite.
0 of 7 done
7 lessons in 4 chapters, about 5 hours on a simulated ESP32-C3-DevKitM-1. Free, in your browser, every step checked by the simulator.
An airlock state machine with names that stay in their scope, never turn into an int by accident, fit in one byte, and make the compiler check every switch.
Open it in the simulatorA constructor takes, a destructor gives back. A lamp guard that survives an early return, a scoped timer that reports itself, and a hand-written version that leaves the lamp on.
Open it in the simulatorAn array template of your own in eight lines, ring buffers of three sizes, and what every new size costs in the build log. Then the shared-base trick, measured: less code, a little more RAM.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
Values and names checked at build time.
Work done by the compiler, not the chip: a Fibonacci number that costs nothing at run time against the 21891 calls it takes live, a lookup table built at build time, and static_assert guarding a blink rate.
0 of 6 steps
An airlock state machine with names that stay in their scope, never turn into an int by accident, fit in one byte, and make the compiler check every switch.
0 of 5 steps
Arrays that know their size, and cleanup you cannot forget.
A fixed array that knows its size and costs nothing extra. No decay to a pointer in a function, range-for, std::sort, and what Mokxi's small standard library does instead of throwing.
0 of 6 steps
A constructor takes, a destructor gives back. A lamp guard that survives an early return, a scoped timer that reports itself, and a hand-written version that leaves the lamp on.
0 of 6 steps
Lambdas, templates, and what they really cost.
Little functions written where they are used: a task table of captureless lambdas, a sort by distance from the Sun, captures by value and by reference, and what each one costs in bytes.
0 of 5 steps
An array template of your own in eight lines, ring buffers of three sizes, and what every new size costs in the build log. Then the shared-base trick, measured: less code, a little more RAM.
0 of 5 steps
A pin driver with no run-time cost.
A pin driver where the pin number is part of the type: every call is one register write, it races digitalWrite and wins by more than ten times, and you add the input half and a blinker built from templates.
0 of 6 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 Modern C++ for microcontrollers 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 ESP32-C3-DevKitM-1 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: enum class, RAII guards and Templates without bloat.
With "constexpr", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.