Home / Learn Embedded C / Your First Blink: a Full Walkthrough
Your First Blink: a Full Walkthrough
Everything from power-on to a blinking LED, explained step by step.
Theory in plain words
Definition
Blinking an LED on a timer is the "Hello, World" of embedded systems: it exercises GPIO output and a delay, and proves your whole toolchain (compiler, flasher, chip) works end to end.
Why you need this
If blink works, you know your board, programmer, and toolchain are all correctly set up — any later bug is almost certainly in your own application code, not your tools.
How it works
Configure a pin as an output, write HIGH, wait, write LOW, wait, repeat forever — the loop never ends because the chip has nothing else to boot into.
Where you'll see this
- First hardware bring-up
- Toolchain smoke test
Try it
On real hardware this loop has no break and runs forever; here we add one so you can see the program finish instead of hitting the 3-second sandbox timeout.
Step by step
- Configure the LED pin as an output (pinMode/direction register).
- In an infinite loop: turn the pin on, delay, turn the pin off, delay.
- Compile with your toolchain, producing a flashable image.
- Flash the image onto the chip.
- Watch the LED blink — and know your whole pipeline works.
Try it: blinking an SOS pattern instead of a steady rate
Same blink skeleton as before, but varying the on/off timing turns a plain blink into a recognizable pattern — the same trick used for status-code LEDs.
Test what you just read
1. Why does the blink program never return from its main loop?
With no OS underneath, returning from main on bare hardware has nothing meaningful to return to, so the loop runs forever by design.