The program
Blink is the first firmware most people write: an LED goes on for a second, off for a second, forever. If it blinks, your board, cable and tools all work. Ours is an Arduino Uno R3 with an LED on pin 13.
Here is the whole program, called a sketch, in Arduino C++. setup() runs once when the board starts. Then loop() runs again and again, as the lesson on setup() and loop() showed.
Press Upload. The IDE compiles the sketch into machine code and sends it down the USB cable. The bootloader, a small program already on the chip, writes it into flash. The lesson "From code to chip: compile, link and flash" shows each stage.
One blink
Line 2: pinMode(13, OUTPUT). After a reset every pin is an input. Inside the chip, pin 13 is bit 5 of port B. Writing 1 to its direction bit, DDRB5, makes it an output the chip can drive.
Line 5: digitalWrite(13, HIGH) sets the output bit PORTB5 to 1, and pin 13 goes to 5 volts. Current flows out of the pin, through the resistor and the LED, to ground. The LED lights.
Line 6: delay(1000) waits 1,000 milliseconds, one second. At 16 MHz, one second is 16 million clock ticks. The program does nothing else, and pin 13 stays at 5 volts, so the LED stays on.
Line 7: digitalWrite(13, LOW) sets PORTB5 back to 0. Pin 13 drops to 0 volts, the same as ground, so no current flows and the LED goes dark.
Line 8: delay(1000) waits one more second with the LED off. Then loop() reaches its closing brace on line 9.
Forever, and faster
loop() ends and starts again at line 5. One blink takes 2 seconds: 1 on, 1 off. That is 30 blinks a minute, 0.5 per second (0.5 hertz). The plot shows pin 13 over 4 seconds.
Change both delays to 200 and upload again. Now one blink takes 0.4 seconds: 2.5 blinks a second. Edit, upload, watch the board: that is how all firmware work goes.
What happens
;; step 1/10 · hello
Blink the "hello, world" of microcontrollers
board Arduino Uno R3 (ATmega328P, 16 MHz)
LED on pin 13, through a 220 ohm resistor
(the board's own "L" LED is on pin 13 too)
it blinks -> board, cable and toolchain all work
The original Blink example writes LED_BUILTIN instead of 13. On the Uno, LED_BUILTIN is defined as 13, so the board's own "L" LED blinks along with yours. On other boards it can be a different pin. The resistor keeps the current safely low. An ATmega328P pin must never carry more than 40 mA (the datasheet's absolute maximum); the lesson "Pin current limits and driving loads with a transistor" shows how to work out the resistor.