Arduino · Einsteiger · Stufe 13 / 40
C++ for Embedded Work: Structure, Classes and Memory
Organise growing programs with structs, classes and multiple files while keeping RAM use under control.
Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo
10 Lektionen in dieser Stufe
- Scope, Lifetime and static Local Variables
Predict where a variable is visible and how long it keeps its value. · Lab: Convert global timestamps into static locals inside task functions. - Fixed-Width Integer Types and Overflow
Use uint8_t, int16_t and uint32_t deliberately and predict wrap-around. · Lab: Trigger and then fix an overflow in a multiplication of two int values. - Bitwise Operators, Masks and Flags
Set, clear, toggle and test individual bits. · Lab: Pack eight on-off settings into one byte and print it in binary. - Grouping Related Data with struct
Define structs and arrays of structs for cleaner data handling. · Lab: Describe each LED channel by a struct of pin, interval and state and loop over an array of them. - Pointers and References Explained with Memory Maps
Read and write through addresses and choose references for function parameters. · Lab: Write a swap function with references and print the addresses of variables. - Passing Arrays and Structs to Functions
Hand larger data to functions efficiently and safely with sizes and const. · Lab: Write a function that computes minimum, maximum and mean of any int array. - Classes: Wrapping a Button into a Reusable Object
Bundle data and behaviour into a class with methods. · Lab: Turn the debounced button code into a Button class with an update and a wasPressed method. - Constructors, Private Members and Multiple Instances
Initialise objects cleanly and hide internal state. · Lab: Create four Button and four Led objects and connect them in ten lines of loop code. - Splitting a Sketch into Header and Source Files
Separate declarations from definitions and use include guards. · Lab: Move the classes into their own .h and .cpp tabs and rebuild. - RAM, Flash and the F Macro: Measuring Memory Use
Distinguish flash, static RAM, stack and heap and keep constant text out of RAM. · Lab: Measure free RAM, move strings to flash with F and PROGMEM and record the gain.
Abschlussprojekt
A multi-file control panel sketch built from reusable Button, Led and Blinker classes that drives four inputs and four outputs with measured RAM use.
Teile für diese Stufe
- 1 × UNO-compatible board
- 1 × USB cable matching the board
- 1 × Solderless breadboard 830 points
- 1 × Jumper wire set male-male
- 4 × Tactile push button
- 4 × LED 5 mm assorted
- 4 × Resistor 220 ohm
In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Arduino-kompatibel →
Voraussetzung: Levels 1–12: functions, arrays, state machines and interrupts.