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.

The short versionEverything from power-on to a blinking LED, explained step by step.

Theory in plain words

The blink loopSet pin HIGHWait (delay)Set pin LOWWait (delay)
The blink loop

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

A full blink programC: edit and run

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

  1. Configure the LED pin as an output (pinMode/direction register).
  2. In an infinite loop: turn the pin on, delay, turn the pin off, delay.
  3. Compile with your toolchain, producing a flashable image.
  4. Flash the image onto the chip.
  5. Watch the LED blink — and know your whole pipeline works.

Try it: blinking an SOS pattern instead of a steady rate

A varied blink pattern using two different delay lengthsC: edit and run

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?