Coding track
C++ for embedded

Learn C++ for embedded systems, on a board

Types with a size, pointers and structs first, then references, classes, ring buffers, templates and code you can test without the hardware.

FreeIn your browser2 courses, 20 lessons, about 16 hours
Start freeVariables have a sizeSee the course
Overview

How you will learn it

Embedded C++ is C++ with a budget: a few kilobytes of memory, no operating system and a board that does exactly what the code says. Learning it on a simulated Arduino means every idea shows up as something the board does.

C++ on a board teaches the language one idea per lesson. C++ that scales adds the habits that keep a big firmware sane: const references, classes, a ring buffer, a state machine class, templates and logic split from the pins so you can test it.

Outcomes

What you will learn

  • Choose types by size and know where integer math throws things away.
  • Use pointers, structs and your own header files.
  • Write classes, ring buffers and state machines for firmware.
  • Split logic from hardware so it can be tested on its own.
Your route

The courses and lessons to take

Every lesson opens in the editor right away, signed in or not, and the simulator checks each step.

  1. Step 1 · 13 lessons · 10 h

    C++ on a board

    The language, one idea per lesson.

    1. Variables have a sizeA box with a name, a type and a value. On this board an int is two bytes, and the sketch shows what happens when a number does not fit.
    2. Where a thing livesA pointer holds an address. The & and * operators, a function that really changes the caller's variable, and why an array is handed over as a pointer.
    3. Things that belong togetherA struct gives one name to the pieces that make up one thing. Three lamps, each with a pin, a rate, a last time and a state, in one array instead of twelve loose variables.
    4. One variable that says where you areA reaction game as four named states and one variable. An enum, one block per state, and a button that moves the machine on. Nothing blocks and nothing is nested.
    Every lesson in the course
  2. Step 2 · 7 lessons · 6 h

    C++ that scales

    The habits real firmware needs.

    1. References and constA copy, a reference and a const reference to one struct: which changes stick, what each one costs, and a swap that only works through references.
    2. A ring bufferA fixed array that behaves like an endless queue: a head and a tail that wrap, overwrite the oldest when full, and a power-of-two capacity the compiler checks.
    3. A state machine classThe elevator rebuilt as a Lift class: enum class states, one private go() that every transition passes through, and settings that belong to the constructor.
    4. Testable logic split from pinsA Morse decoder cut in two: logic that takes plain numbers and never touches a pin, so setup() can test it, and a thin pin layer. Find a bug with a test, fix it, move the logic to its own file.
    Every lesson in the course
Keep going

Guides and tools on the same subject

Track

Coding track

Python and C++ from your first print to classes, tests and state machines. Every program runs on a simulated board, so a bug is something you can see.

See the whole track
Questions

Questions people ask

Is Arduino code real C++?

Yes. A sketch is C++ compiled by the same compiler embedded professionals use, with a few helper functions on top.

C or C++ for embedded?

Both are used. C++ adds classes, references and templates that make bigger firmware easier to organize, and it can do everything C does.

Do I need to know C first?

No. C++ on a board starts from a program that is a list of steps and builds up.