YOUR COMPUTERUNO R3avr-g++linker.hex16U2core.aATmega328P0x00000x7E00boot1void loop() {2 digitalWrite(13, HIGH);3 delay(1000);4 digitalWrite(13, LOW);5 delay(1000);6}01.cpp.o.a.elfRSTp0p1p2read=
Left: your computer and its toolchain (compiler, core library, linker, .hex file)Right: the Arduino Uno (USB chip, microcontroller with its flash, LED on pin 13)Tokens: files, bytes on the cable, the reset pulse and 128-byte flash pagesYour computer runs the toolchain: the Blink sketch is tidied into C++, compiled by avr-g++ into a .o file, linked with core.a into one program and written out as a .hex file of at most 32,256 bytes. avrdude sends it over USB at 115,200 bits per second; the ATmega16U2 resets the ATmega328P into its bootloader at 0x7E00, which writes 128-byte pages from 0x0000. After a read-back check the chip runs the program and the LED on pin 13 blinks.

Build on your computer

  1. Here is Blink, a sketch that flashes the LED on pin 13. To the chip it is just letters. The chip only runs machine code: numbers in its flash memory. A toolchain, a set of programs on your computer, does the translating.

Flash it onto the chip

Run

What happens

;; step 1/10 · source
board      Arduino Uno R3  (chip: ATmega328P)
sketch     Blink.ino, plain text
the chip   runs machine code only: numbers in flash
toolchain  the programs that turn text into those numbers

// Blink, for the Arduino Uno R3: the on-board LED is on pin 13
void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

The card shows only loop(), with the pin written as 13. The real example writes LED_BUILTIN, which is pin 13 on the Uno, and setup() calls pinMode(LED_BUILTIN, OUTPUT). The commands are shortened. The Arduino tools also pass warnings, include paths and link-time optimisation (-flto), compile the core's own files, and run each step for you when you press Upload.