Arduino · Einsteiger · Stufe 3 / 40
Digital Outputs and the Building Blocks of C++
Control several LEDs from digital pins using variables, loops and your own functions.
Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo
10 Lektionen in dieser Stufe
- Driving an External LED from a Digital Pin
Use pinMode and digitalWrite to switch a pin between 0 V and 5 V. · Lab: Move your LED circuit from the 5 V pin to pin 8 and blink it. - Variables and Constants: Giving Pins and Times a Name
Declare int variables and const values and use them instead of bare numbers. · Lab: Rewrite Blink so pin number and delay are named constants, then change them in one place. - Integer Types and Arithmetic in Sketches
Use int, long and byte with the arithmetic operators and predict integer division results. · Lab: Make each blink 50 ms shorter than the last until it restarts at one second. - Repeating Work with for Loops
Write counted loops with a start, a condition and a step. · Lab: Blink an LED exactly five times, pause, and repeat. - while Loops and Counting Down
Use while for repetition that depends on a changing condition. · Lab: Create a countdown where blinks speed up until a final long flash. - Writing Your Own Functions with Parameters
Define void functions that take arguments to remove repeated code. · Lab: Write flash(pin, times, duration) and call it for three different LEDs. - Functions That Return Values
Return a computed result from a function and use it in an expression. · Lab: Write a function that returns a delay from a step number and use it in a chase effect. - Pin Current Limits and Sharing Load Across Pins
Stay within per-pin and total current limits of the ATmega328P. · Lab: Calculate and measure the total current of eight LEDs and decide on safe resistor values. - Six-LED Running Light on Consecutive Pins
Combine a for loop with pin numbers to animate a row of LEDs in both directions. · Lab: Build a bouncing light on pins 2–7 with adjustable speed constant. - Sequencing a Traffic Light with Named Phases
Structure a timed sequence into clearly named phase functions. · Lab: Program one traffic light through red, red-yellow, green and yellow with realistic timings.
Abschlussprojekt
A two-way traffic light model with correct phase timing, written with named constants and reusable functions.
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
- 8 × Resistor 220 ohm
- 3 × LED 5 mm red
- 2 × LED 5 mm yellow
- 3 × LED 5 mm green
- 1 × Digital multimeter
In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Arduino-kompatibel →
Voraussetzung: Levels 1–2: uploading sketches, breadboard circuits and LED resistor calculation.