Programming

Hello World, Embedded Edition: Blink an LED

Embedded C: Hello WorldNeeded DocumentationArduino Nano PCB designAtmega328P datasheetMaterials usedArduino NanoArduino Uno R3Relevant cableComputerSoftware Usedmake (for easy of compiling and building)avr-gcc (our compiler for avr ISA)binutils-avravr-libcavrdude (used to flash board)The…

Hello World, Embedded Edition: Blink an LED

The embedded hello world isn't text — it's a blinking LED. It teaches the same thing printf teaches beginners: the toolchain works, the code reaches the hardware, and you control something real.

No standard library, no OS — a datasheet, a register map and GPIO. On an STM32 the blink is: enable the GPIO port clock, set the pin mode to output, then flip the pin in a loop with a delay. Every step writes a hardware register; the LED is the visible side effect of a memory write.

RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;   // clock on
GPIOA->MODER |= (1 << (5 * 2));        // PA5 = output
while (1) {
    GPIOA->ODR ^= (1 << 5);           // toggle
    for (volatile int i = 0; i < 500000; i++);
}

Why it's the right first program

Blink proves the whole pipeline at once: cross-compiler, flashing tool, board, code. When the LED blinks, everything worked — when it doesn't, you've localized the failure to exactly one stage. Embedded's version of "it compiled" is "it blinked."

What it leads to

UART "hello world" is the real next step — serial output gives you printf again, this time through a wire. Then interrupts, then peripherals. The LED blink is how you verify you're speaking the board's language.

$ tail -f /forums

Discussion

Comments live on the community forums — sign in there to reply.