Arduino Uno: Complete Interactive Guide, Pinout & Specs

Cover image for the complete Arduino Uno guide covering pinout, specifications, calculators and projects
Arduino Uno Field Manual
eARgle Innovation Labs · Embedded Foundations

An interactive field manual for the board that taught a generation to blink an LED — every pin, every limit, and the twelve things that quietly break your first project.

Updated October 2026 Beginner → Intermediate ~35 min read 9 interactive tools
16MHz clock
32KB flash
2KB SRAM
14Digital I/O
6PWM pins
10Bit ADC
01 · Orientation

What an Arduino Uno actually is

Strip away the branding and an Arduino Uno is three things bolted to one piece of fibreglass: an 8-bit ATmega328P microcontroller running at 16 MHz, a second chip whose only job is to translate USB into serial so you can talk to the first one, and a set of header sockets that bring every useful leg of that microcontroller out to somewhere a jumper wire can reach.

That is the whole trick. The ATmega328P on its own is a 28-pin chip that needs a crystal, a programmer, a regulated supply and a breadboard before it will do anything. The Uno is that chip pre-wired with all of its inconvenient requirements already solved, so the first thing you have to learn is code, not soldering.

It is deliberately, almost stubbornly, under-powered. A modern ESP32 has roughly 16× the SRAM, 8× the flash and a clock fifteen times faster, plus Wi-Fi. The Uno survives anyway, for four reasons that matter more than specifications:

  • It is 5 V native. The vast catalogue of hobby sensors, relay boards and motor drivers built for 5 V logic plug straight in with no level shifting.
  • It is deterministic. No Wi-Fi stack, no RTOS, no background tasks stealing cycles. Your loop() is the only thing running, so timing you measure is timing you get.
  • It is hard to kill. A DIP-28 socket version lets you replace a dead microcontroller for pocket change; the rest of the board tolerates abuse that would end a bare ESP module.
  • It is the reference. Two decades of tutorials, shields, libraries and school syllabi assume this pinout. When something goes wrong, somebody has already written it down.
Arduino Uno R3 development board seen from above, showing the ATmega328P microcontroller, USB-B socket and the digital and analog header pins
The board that has not meaningfully changed since 2010. The long black chip is the ATmega328P; everything else exists to make it convenient.Photo: Arduino · CC BY-SA 4.0 · padded to 3:2, otherwise unaltered
Which Uno do you have?

Flip the board over, or look next to the USB socket. A USB-B printer-style socket and a long black DIP chip means Uno R3 (ATmega328P) — the board this guide is built around. A USB-C socket means Uno R4, which keeps the same shape and 5 V pins but swaps in a 48 MHz 32-bit Renesas chip. Nearly everything here still applies to the R4; the comparison table marks the places it does not.

02 · Board tour

Every component on the board, and why it is there

Tap any part of the diagram. Twelve components do all the work — and two of them are microcontrollers, which surprises most people.

Interactive

Board anatomy explorer

A schematic layout, not a photograph — parts are drawn where they sit, sized for legibility.

DIGITAL D0 — D13 POWER ANALOG IN USB-B 7–12 V DC REG FUSE 16U2 16 MHz L TX RX ON RESET ATmega328P 8-bit AVR · 16 MHz ICSP
Schematic layout of an Uno R3. Part sizes are exaggerated for legibility — the real board is 68.6 × 53.4 mm.
16U216.000USB-Bpower + dataATmega16U22nd microcontroller16 MHz crystalthe clock sourceregulatorspare volts → heatDC jack7–12 VA schematic of the R3’s left edge — the five parts handling power and USB. Not to scale.
The left edge of the board, where power and USB are handled. Two of these five parts are ones beginners never notice: the crystal every timing function derives from, and the second microcontroller.
03 · Reference

The complete Uno pinout, pin by pin

Thirty documented connections. Filter by role, search by name, then tap a pin for its port register, alternate functions, current limit and the mistake people make with it.

Interactive

Pinout explorer

Colour on the left edge of each pin encodes its silicon role, not its position on the board.

The A6 / A7 trap

Pinout diagrams scraped from the Nano show A6 and A7. The Uno does not have them. The DIP-28 ATmega328P package simply does not bring those two ADC channels out to a leg — they exist only on the surface-mount TQFP/QFN versions used by the Nano and Pro Mini. Code referencing A6 on an Uno compiles happily and then reads garbage.

04 · Numbers

Specifications, and how the Uno compares

The first table is the Uno R3 datasheet reduced to what you will actually hit. The second shows when to stop reaching for an Uno.

Arduino Uno R3 technical specifications
ParameterValueWhat this means in practice
MicrocontrollerATmega328P8-bit AVR, Harvard architecture, 131 instructions
Clock speed16 MHz62.5 ns per cycle; most instructions run in 1–2 cycles
Flash memory32 KB0.5 KB taken by the bootloader → 31.5 KB for your sketch
SRAM2 KBAll variables, buffers and the stack share 2,048 bytes
EEPROM1 KBSurvives power-off; rated ~100,000 writes per cell
Digital I/O pins14 (D0–D13)D0/D1 are shared with USB serial — treat as 12 free
PWM outputs6 (D3, 5, 6, 9, 10, 11)8-bit duty, 490 Hz or 980 Hz depending on timer
Analog inputs6 (A0–A5)10-bit, 0–1023, one shared ADC multiplexed between them
ADC resolution10-bit4.88 mV per step at the default 5 V reference
ADC conversion time~100 µsCeiling of roughly 9,600 analogRead() calls per second
DC current per I/O pin20 mA recommended40 mA is the absolute maximum — past it the pin driver degrades
Total I/O current200 mAHard ceiling through the VCC and GND legs of the chip
3.3 V pin current50 mAComes from a small LDO, not the main regulator — easily overloaded
Operating voltage5 V logicHIGH is ~5 V out; inputs read HIGH above about 3.0 V
Input voltage (jack)7–12 V recommendedAbsolute limits 6–20 V; above 12 V the regulator cooks
USB protection500 mA polyfuseResettable — it opens on overload and recovers when you unplug
External interrupts2 (D2 = INT0, D3 = INT1)Only these two work with attachInterrupt() in the core
Hardware timers3 (Timer0/1/2)Timer0 runs millis(); Timer1 is claimed by Servo
Board size / weight68.6 × 53.4 mm / 25 gThe shield form factor every Uno-compatible board copies
Arduino Uno R3 compared with the Uno R4, Nano, Mega 2560 and ESP32
 Uno R3Uno R4 MinimaUno R4 WiFiNanoMega 2560ESP32 DevKit
MCUATmega328PRA4M1RA4M1ATmega328PATmega2560ESP32
Bits / clock8 / 16 MHz32 / 48 MHz32 / 48 MHz8 / 16 MHz8 / 16 MHz32 / 240 MHz
Flash32 KB256 KB256 KB32 KB256 KB4 MB
SRAM2 KB32 KB32 KB2 KB8 KB520 KB
Logic level5 V5 V5 V5 V5 V3.3 V
ADC bits101414101012
True DACNo1 × 12-bit1 × 12-bitNoNo2 × 8-bit
Digital I/O1414141454~34
Wi-Fi / BLENoNoYesNoNoYes
USB socketUSB-BUSB-CUSB-CMini/MicroUSB-BMicro/USB-C
Jack input7–12 V6–24 V6–24 VNone7–12 VNone
Shield compatibleYesYesYesNoYesNo
Reach for it whenLearning, 5 V sensors, shieldsSame shape, more headroomUno shape plus IoTBreadboard buildsYou ran out of pinsWi-Fi, heavy maths

Read that last row carefully. Ninety per cent of “I need to upgrade from the Uno” turns out to be one of two things: out of pins (go Mega) or out of SRAM (go R4 or ESP32). If you are weighing the jump, our ESP32 vs ESP8266 vs Arduino Uno R4 comparison works through it properly. Clock speed is almost never the bottleneck in a hobby project — at 16 MHz you still get around a million loop() iterations a second if you stop calling delay().

05 · The real constraint

2 KB of SRAM is the thing that will bite you

The Uno has three separate memories and beginners routinely confuse them:

  • Flash — 32 KB. Your compiled program. Non-volatile. The bootloader eats 512 bytes, leaving 32,256 for you. The IDE tells you how much you used.
  • SRAM — 2 KB. Every variable, every array, every buffer, plus the call stack, all in 2,048 bytes. Volatile. The IDE’s estimate here is a guess, because it cannot see what your code allocates at runtime.
  • EEPROM — 1 KB. Non-volatile storage for settings you want to survive a power cut. Slow to write (~3.3 ms per byte) and wears out after roughly 100,000 writes per cell.

Flash is rarely the problem. SRAM is almost always the problem, and it fails in the worst possible way: not with an error, but with your board silently rebooting, printing nonsense, or freezing — because the stack grew down into your variables and corrupted them. Budget it deliberately.

Calculator

SRAM budget

Add what your sketch uses. Keep the total under about 1,500 bytes so the stack has room to breathe.

0 BUsed
2048 BFree
0%Of 2 KB

Three fixes that reclaim hundreds of bytes

Every string literal you hand to Serial.print() is copied from flash into SRAM when the board boots, and stays there forever. Wrapping it in F() leaves it in flash and streams it out character by character:

sram-savers.ino
// 1. Keep string literals in flash with F() — saves 1 byte per character
Serial.println("Temperature sensor ready");     // 25 bytes of SRAM, gone forever
Serial.println(F("Temperature sensor ready"));  // 0 bytes of SRAM

// 2. Pick the smallest type that fits. A pin number is never a 2-byte int.
int      ledPin = 13;   // 2 bytes
uint8_t  ledPin = 13;   // 1 byte  — range 0..255

// 3. Avoid the String class. It fragments the heap and crashes slowly.
String msg = "val: "; msg += value;      // heap churn, unpredictable
char msg[16]; snprintf(msg, sizeof(msg), "val: %d", value);  // fixed, safe

// 4. Read your actual free SRAM at runtime — the only honest number
int freeRam() {
  extern int __heap_start, *__brkval;
  int v;
  return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
}
Habit worth forming

Print freeRam() in setup() and once a second in loop() while developing. If the number drifts downward over minutes, you have a leak — almost certainly String concatenation inside the loop.

06 · Power

Three ways in, and the arithmetic that stops the brownouts

More first projects die from an honest power mistake than from bad code.

The three input paths

  • USB (5 V). Goes through a 500 mA resettable polyfuse straight onto the 5 V rail, bypassing the regulator. Your laptop port typically offers 500 mA total, and the board itself idles at roughly 45 mA. Call it 450 mA for everything you add.
  • Barrel jack (7–12 V). Feeds the on-board linear regulator. Linear means the excess voltage becomes heat, not saved energy: at 12 V in and 300 mA out, the regulator burns (12 − 5) × 0.3 ≈ 2.1 W as heat. It will get too hot to touch and then thermally shut down. 9 V is the sweet spot.
  • VIN pin. Electrically the same as the jack, minus the reverse-polarity diode. Convenient and unforgiving — one swapped wire kills the board.
Never do this

Do not feed regulated 5 V into the 5 V pin while USB is also connected, and do not feed 5 V into VIN. The 5 V pin is an output of the regulator; back-driving it fights the regulator and bypasses every protection on the board. And 5 V into VIN leaves the regulator with no headroom, so the chip browns out at around 4.2 V and behaves erratically rather than failing cleanly.

USB-B5 V from hostpolyfuse500 mA, resettableDC jack7–12 Vreverse diodepolarity protectionVIN pin7–12 Vno diode — oneswapped wire kills itregulatorlinear · excess → heat5 V railATmega328P~20 mA5 V pinout to your parts3V3 LDOseparate, 50 mA maxI/O pins: 20 mA each,200 mA totalThe 5 V pin is an OUTPUT of this rail. Feeding power into it fights the regulatorand bypasses the fuse.
Three ways in, one rail out. The figure on each path is the limit you actually hit, not a theoretical maximum.

The four current limits, in order of how often they are broken

  1. 20 mA per pin (40 mA absolute). One LED per pin is fine. A motor, a relay coil or a strip of LEDs is not.
  2. 200 mA total across all I/O pins together, limited by the chip’s own VCC/GND legs.
  3. 50 mA from the 3.3 V pin. This rail comes from a small LDO in the USB section, not the main regulator. An ESP-01 module peaking at 300 mA will crash the board instantly.
  4. ~450 mA usable on the 5 V rail from USB, or roughly 800 mA from the jack before the regulator’s heat becomes the limit.
Calculator

Current budget

Pick your parts. The verdict checks typical draw, peak draw and whether anything is too hungry to hang off a pin.

Supply
45 mATypical
45 mAPeak
450 mABudget
405 mAHeadroom
The resistor every LED needs

An LED is a diode, not a resistor — connect one directly across 5 V and it draws whatever current it can until something gives. Size the resistor from Ohm’s law: R = (5 V − Vf) / I. A red LED drops about 2.0 V and wants 15 mA, so (5 − 2.0) / 0.015 = 200 Ω — use the standard 220 Ω. A blue or white LED drops around 3.2 V, so (5 − 3.2) / 0.015 = 120 Ω. When in doubt, 330 Ω is dimmer and always safe.

07 · Digital I/O

Three pin modes, and the one that saves you a resistor

Every digital pin has exactly three useful configurations, set with pinMode():

OUTPUT

The pin pushes

It actively drives either 5 V (HIGH) or 0 V (LOW), sourcing or sinking up to 20 mA. Use it for LEDs, transistor gates and signal lines.

INPUT

The pin listens, weakly

High impedance — it reads voltage without affecting it. With nothing connected it floats, picking up mains hum and reading randomly. This is the classic phantom-button bug.

INPUT_PULLUP

The pin listens, and holds itself up

Enables an internal ~20–50 kΩ resistor to 5 V, so the pin idles HIGH. Wire your button from the pin to GND and pressing it reads LOW. No external resistor, no floating.

THE LOGIC INVERTS

Pressed means LOW

This trips everyone once. With INPUT_PULLUP the reading is inverted: if (digitalRead(2) == LOW) means pressed. Write it as if (!digitalRead(2)) and move on.

inside the ATmega328P5 Vinternal pull-up20–50 kΩD2push buttonGNDidle → reads HIGHthe resistor holds the pin at 5 Vpressed → reads LOWthe button shorts it to ground
No external resistor, and the logic inverts: pressed reads LOW.
D9220 ΩLEDlong leg to the resistorGNDsizing the resistorR = (5 V − Vf) / Ired LED: Vf ≈ 2.0 V(5 − 2.0) / 0.015 = 200 Ω→ use the standard 220 ΩBlue or white LED? Vf ≈ 3.2 V, so (5 − 3.2) / 0.015 = 120 Ω.Unsure? 330 Ω is dimmer and always safe. Never connect an LED without one.
The resistor is not optional. Size it from the LED’s forward voltage.
button-done-right.ino
// Button from pin 2 to GND. No external resistor needed.
// Debounced with millis() so one press is never counted twice.

const uint8_t BUTTON = 2;
const uint8_t LED    = 13;
const uint16_t DEBOUNCE_MS = 40;   // contacts settle in ~20-30 ms

bool     lastStable  = HIGH;      // pull-up means idle is HIGH
bool     lastReading = HIGH;
uint32_t lastChange  = 0;
bool     ledOn       = false;

void setup() {
  pinMode(BUTTON, INPUT_PULLUP);   // internal resistor to 5 V
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  bool reading = digitalRead(BUTTON);

  // Any change restarts the settling clock
  if (reading != lastReading) {
    lastReading = reading;
    lastChange  = millis();
  }

  // Accept the level only once it has held still long enough
  if (millis() - lastChange >= DEBOUNCE_MS && reading != lastStable) {
    lastStable = reading;
    if (lastStable == LOW) {          // LOW == pressed
      ledOn = !ledOn;
      digitalWrite(LED, ledOn);
      Serial.println(F("press"));
    }
  }
}
Why millis() - lastChange and never millis() > lastChange + 40

millis() returns an unsigned long that wraps to zero after 49.7 days. Subtraction of unsigned values wraps correctly and keeps working across that rollover; addition on the right-hand side does not. Write the subtraction form every time and the bug never exists.

08 · PWM

The Uno cannot output 2.5 V — so it fakes it very fast

There is no DAC on an ATmega328P. analogWrite() switches the pin fully on and fully off hundreds of times a second and lets the average do the work.

Interactive

PWM lab

Drag the duty cycle. Watch the waveform, the average voltage, and why a linear fade looks wrong to your eye.

5V 0V avg one period
Three periods shown. The orange line is the average voltage a slow meter — or an LED — actually sees.
64Value
25.1%Duty cycle
1.25 VAverage
510 µsOn time

Left: brightness set linearly.
Right: gamma-corrected.
Same value — the right one is what your eye expects.

The gamma problem is the most useful thing in that panel. Human brightness perception is roughly logarithmic, so analogWrite(128) — mathematically half power — looks about 73% as bright, not 50%. A linear fade therefore appears to rush through the dim end and crawl through the bright end. Correct it with a power curve:

smooth-fade.ino
// A fade that actually looks linear. Pin 9 = Timer1 PWM.
const uint8_t LED_PIN = 9;
const float   GAMMA   = 2.2;   // matches eye response closely enough

void setup() { pinMode(LED_PIN, OUTPUT); }

void loop() {
  for (int step = 0; step <= 255; step++) {
    // Map perceived brightness 0..1 onto real duty 0..255
    float perceived = step / 255.0;
    uint8_t duty = (uint8_t)(pow(perceived, GAMMA) * 255.0 + 0.5);
    analogWrite(LED_PIN, duty);
    delay(8);
  }
  for (int step = 255; step >= 0; step--) {
    float perceived = step / 255.0;
    analogWrite(LED_PIN, (uint8_t)(pow(perceived, GAMMA) * 255.0 + 0.5));
    delay(8);
  }
}

// Short on flash? Replace pow() with a 32-entry lookup table in PROGMEM.
// pow() and float maths together cost roughly 2 KB of flash on AVR.
The Servo library steals pins 9 and 10

Servo.h takes over Timer1 to generate its 50 Hz pulses. The moment you call servo.attach(), analogWrite() on pins 9 and 10 stops working — silently. Move your PWM output to pin 3, 5, 6 or 11 and the conflict disappears.

09 · Analog input

Ten bits, one converter, six pins taking turns

There is exactly one analog-to-digital converter inside the ATmega328P. A multiplexer switches it between A0–A5, which is why you cannot sample two pins at the same instant — analogRead() selects a channel, waits for it to settle, converts for about 100 µs, and returns.

The result is a number from 0 to 1023, mapping 0 V to the reference voltage. With the default 5 V reference each step is 5 / 1023 = 4.888 mV.

Converter

ADC converter

Slide a voltage in and read what analogRead() gives back — in decimal, binary and mapped units.

1.65 VInput
338analogRead()
010101001010-bit binary
33map() to 0–100
4.888 mVStep size

1023 or 1024? The argument that will not die

To convert a reading back to volts, divide by 1023: the ADC output is a ratio where 1023 represents full scale, so volts = raw * 5.0 / 1023.0 puts 1023 at exactly 5 V. The people arguing for 1024 are describing the converter’s internal quantisation step, which is Vref/1024. Both are right about different things; for reading a sensor, use 1023. The difference is 0.1%, far smaller than your supply’s own error.

Your 5 V is not 5 V

On USB power the rail is typically 4.6–4.9 V, and it sags when the board works harder. Since the default reference is that rail, every analog reading drifts with it. For measurements that have to be accurate, either measure the actual rail with the 1.1 V internal bandgap trick, or feed a precision reference into AREF and call analogReference(EXTERNAL) — before the first analogRead(), or you short the internal reference to your external one.

clean-analog-read.ino
// Potentiometer on A0. Oversampled and smoothed, because one raw
// analogRead() on a breadboard jitters by several counts.

const uint8_t POT = A0;
const uint8_t SAMPLES = 16;        // 16 reads ~ 1.6 ms, kills most noise
float smoothed = 0;
const float ALPHA = 0.2;            // 0 = frozen, 1 = no smoothing

void setup() {
  Serial.begin(9600);
  analogRead(POT);                   // throw the first one away: the mux
}                                    // needs a moment after switching

void loop() {
  uint32_t total = 0;
  for (uint8_t i = 0; i < SAMPLES; i++) total += analogRead(POT);
  float raw = total / (float)SAMPLES;

  // Exponential moving average — one float, no history array
  smoothed = ALPHA * raw + (1.0 - ALPHA) * smoothed;

  float volts = smoothed * 5.0 / 1023.0;
  int   percent = map((int)smoothed, 0, 1023, 0, 100);

  Serial.print(F("raw "));  Serial.print(smoothed, 1);
  Serial.print(F("  V "));   Serial.print(volts, 3);
  Serial.print(F("  % "));   Serial.println(percent);
  delay(50);
}
10 · Timing

delay() is the first thing you learn and the first thing to unlearn

During delay(1000) the processor does nothing at all. It cannot read a button, feed a sensor or answer a serial command. Try it below.

Simulator

Blocking vs non-blocking

Both LEDs blink at the same rate. Hammer both buttons — only one board is listening.

delay() — blocking

Pressed 0 · registered 0 · — response rate

loop() {
  digitalWrite(LED, HIGH);
  delay(250);        // deaf
  digitalWrite(LED, LOW);
  delay(250);        // deaf
  checkButton();     // 1 chance
}

millis() — non-blocking

Pressed 0 · registered 0 · — response rate

loop() {
  if (millis() - t >= 250) {
    t = millis();
    toggleLed();
  }
  checkButton();     // every pass
}
Red bars are time spent inside delay(). The green listening slivers are widened here to stay visible — in a real sketch they are microseconds wide, so a real board misses even more than this one does.

The pattern that replaces delay() everywhere is the same four lines, and once it is muscle memory you can run six independent timed tasks on one 16 MHz chip without a scheduler:

three-tasks-one-loop.ino
// Three jobs at three different rates, zero delay() calls.
// Each task owns one timestamp variable. That is the whole technique.

const uint8_t LED = 13, BUZZER = 8, POT = A0;

uint32_t tLed = 0, tSensor = 0, tReport = 0;
const uint16_t LED_MS = 500, SENSOR_MS = 50, REPORT_MS = 1000;

bool ledOn = false;
int  lastValue = 0;

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t now = millis();          // read the clock once per pass

  // Task 1: blink, twice a second
  if (now - tLed >= LED_MS) {
    tLed = now;
    ledOn = !ledOn;
    digitalWrite(LED, ledOn);
  }

  // Task 2: sample the pot, 20 times a second
  if (now - tSensor >= SENSOR_MS) {
    tSensor = now;
    lastValue = analogRead(POT);
    if (lastValue > 900) tone(BUZZER, 2000, 30);   // alarm, non-blocking
  }

  // Task 3: report, once a second
  if (now - tReport >= REPORT_MS) {
    tReport = now;
    Serial.print(F("pot=")); Serial.println(lastValue);
  }

  // The loop still runs ~100,000 times a second, so a button added
  // here would respond in microseconds.
}

When delay() is still fine

Dogma helps nobody. Use delay() freely for short waits a datasheet demands — delay(2) after powering a sensor, a delayMicroseconds(10) trigger pulse — and in sketches that genuinely have one job. The rule is about long delays in loops that need to stay responsive.

Timing functions on the Arduino Uno
FunctionReturns / rangeRolls overNotes
millis()unsigned long ms49.7 daysDriven by Timer0; stops during interrupts
micros()unsigned long µs71.6 minutesResolution is 4 µs, not 1 µs
delay(ms)——Blocks; interrupts still fire
delayMicroseconds(us)——Reliable to ~16383 µs; busy-waits

Interrupts: for the events you cannot afford to miss

Only D2 (INT0) and D3 (INT1) support attachInterrupt(). An interrupt service routine runs the instant the pin changes, no matter what loop() is doing — which makes it perfect for rotary encoders, flow meters and tachometers, and dangerous everywhere else.

interrupt-counter.ino
// Counting pulses from a flow meter or encoder on pin 2.
// Rules of an ISR: be fast, touch only volatile variables,
// never call delay(), Serial.print(), millis()-dependent waits,
// and never allocate memory.

const uint8_t SENSOR = 2;
volatile uint32_t pulses = 0;     // volatile: changed outside loop()

void onPulse() { pulses++; }       // one instruction is ideal

void setup() {
  pinMode(SENSOR, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(SENSOR), onPulse, FALLING);
  Serial.begin(9600);
}

void loop() {
  static uint32_t t = 0;
  if (millis() - t >= 1000) {
    t = millis();

    // Copy the shared counter with interrupts off, or a pulse
    // arriving mid-read gives you a torn 32-bit value.
    noInterrupts();
    uint32_t count = pulses;
    pulses = 0;
    interrupts();

    Serial.print(count); Serial.println(F(" pulses/s"));
  }
}
Two ISR rules that cause silent lock-ups

First, Serial.print() inside an ISR will eventually hang the board — it waits on an interrupt that cannot fire while you are already inside one. Second, any variable shared between an ISR and loop() must be volatile, or the compiler will cache it in a register and your loop will read a stale value forever.

11 · Communication

Serial, I²C and SPI — three buses, three sets of stolen pins

Every bus on the Uno is wired to specific pins, and using a bus means giving those pins up. Knowing which ones in advance saves a rebuild.

Communication buses and their pins
BusPinsSpeedDevicesCost of using it
UART (Serial)D0 RX, D1 TX300–115200 baud1 per busD0 and D1 are shared with USB — you lose the Serial Monitor
I²C (Wire)A4 SDA, A5 SCL100 / 400 kHz~112 addressableTwo analog inputs; needs pull-ups (usually on the module)
SPID10 SS, D11 MOSI, D12 MISO, D13 SCKUp to 8 MHzMany, one CS pin eachFour digital pins, including the LED pin and a PWM pin
SoftwareSerialAny two digital≤ 57600 reliable1 at a timeBlocks during transfer; cannot send and receive at once

I²C is the one to prefer. Two wires carry an OLED display, a temperature sensor, a real-time clock and an accelerometer all at once, each answering to its own address. The duplicate SDA/SCL pins printed above D13 on an R3 board are the same two pins as A4 and A5 — not extras.

i2c-scanner.ino
// The first sketch to run on any I2C problem. Lists every device
// that answers on the bus, so you stop guessing addresses.
// Wiring: module SDA -> A4, SCL -> A5, VCC -> 5V, GND -> GND

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  while (!Serial) { ; }            // harmless on Uno, needed on some boards
  Serial.println(F("Scanning I2C bus..."));

  uint8_t found = 0;
  for (uint8_t addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if (Wire.endTransmission() == 0) {   // 0 means the device ACKed
      Serial.print(F("  found 0x"));
      if (addr < 16) Serial.print('0');
      Serial.println(addr, HEX);
      found++;
    }
  }
  if (!found) Serial.println(F("  nothing. Check SDA/SCL and power."));
  else      { Serial.print(found); Serial.println(F(" device(s)")); }
}

void loop() { }

// Common addresses: 0x3C SSD1306 OLED, 0x27 or 0x3F LCD backpack,
// 0x68 DS3231/MPU6050, 0x76 or 0x77 BMP280/BME280, 0x48 ADS1115
Why the Serial Monitor shows □□□ garbage

Nine times out of ten, the baud rate in the Monitor’s dropdown does not match the number in Serial.begin(). The remaining time it is a clone board whose resonator is off-frequency at 115200 — drop to 9600 and the garbage disappears.

12 · Anatomy of a sketch

What actually happens when you press Upload

Step through Blink one line at a time. Every Arduino program has this skeleton, and the two functions are not optional.

Walkthrough

Sketch stepper

Line by line, with what the chip is doing at that moment.

Blink.inoline 1 of 12

          

Behind the Upload button, four things happen in sequence. The IDE compiles your sketch with avr-gcc into a .hex file. It then toggles the serial port’s DTR line, which — through a 100 nF capacitor on the board — yanks the ATmega328P’s RESET pin low. The bootloader in the top 512 bytes of flash wakes up, listens for about a second, and avrdude streams the new program in. Then the bootloader jumps to your code and gets out of the way.

That capacitor explains a mystery

Opening the Serial Monitor also toggles DTR, which resets your board and restarts your sketch from scratch. If you have ever wondered why your counter went back to zero the moment you opened the Monitor, that is why. It is a feature — it lets upload work without you pressing Reset by hand.

13 · Build it

Six projects, in the order that teaches the most

Each one introduces exactly one new idea and reuses everything before it. Every sketch here is complete — copy, upload, run.

Project 1 — Blink, done the grown-up way

New idea: non-blocking timing from the very first sketch, so you never have to unlearn it.

Parts: nothing. Pin 13 has an LED already soldered on.

01-blink.ino
const uint8_t LED = LED_BUILTIN;      // == 13 on an Uno
const uint16_t INTERVAL = 500;         // ms between changes

uint32_t lastToggle = 0;
bool     state = LOW;

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  if (millis() - lastToggle >= INTERVAL) {
    lastToggle = millis();
    state = !state;
    digitalWrite(LED, state);
  }
}

Make it yours: add a second LED on pin 9 that blinks every 330 ms. Two timestamps, two if blocks, and they drift in and out of sync — proof the loop is handling both.

Project 2 — Pedestrian crossing with a request button

New idea: a state machine. Three LEDs, one button, and no delay() anywhere — the button stays live through the whole sequence.

Parts: red / amber / green LEDs with 220 Ω resistors on pins 11, 12, 13; push button from pin 2 to GND.

02-crossing.ino
// A state machine: the sketch is always in exactly one named state,
// and each state knows what comes next and when.

const uint8_t RED = 11, AMBER = 12, GREEN = 13, BUTTON = 2;

enum Phase { GO, REQUESTED, WARN, STOP, CLEARING };
Phase    phase   = GO;
uint32_t tPhase = 0;

void setPhase(Phase p) { phase = p; tPhase = millis(); }

void lights(bool r, bool a, bool g) {
  digitalWrite(RED, r); digitalWrite(AMBER, a); digitalWrite(GREEN, g);
}

void setup() {
  pinMode(RED, OUTPUT); pinMode(AMBER, OUTPUT); pinMode(GREEN, OUTPUT);
  pinMode(BUTTON, INPUT_PULLUP);
  setPhase(GO);
}

void loop() {
  uint32_t held = millis() - tPhase;
  bool pressed = (digitalRead(BUTTON) == LOW);   // checked every pass

  switch (phase) {
    case GO:
      lights(false, false, true);
      // Traffic gets a guaranteed 3 s of green before we interrupt
      if (pressed && held > 3000) setPhase(REQUESTED);
      break;

    case REQUESTED:                       // brief acknowledgement
      lights(false, false, true);
      if (held > 500) setPhase(WARN);
      break;

    case WARN:
      lights(false, true, false);
      if (held > 2000) setPhase(STOP);
      break;

    case STOP:                            // pedestrians cross
      lights(true, false, false);
      if (held > 6000) setPhase(CLEARING);
      break;

    case CLEARING:                        // red + amber together
      lights(true, true, false);
      if (held > 1500) setPhase(GO);
      break;
  }
}

Make it yours: flash the amber during CLEARING at 4 Hz. You will need a second timestamp inside that state — the moment you add it, the technique clicks.

Project 3 — Potentiometer dimmer with a dead zone

New idea: analog in driving PWM out, plus the two fixes every real analog input needs — hysteresis and end-stop snapping.

Parts: 10 kΩ potentiometer (outer legs to 5 V and GND, wiper to A0); LED with 220 Ω on pin 9.

03-dimmer.ino
const uint8_t POT = A0, LED = 9;
const uint8_t DEADBAND = 4;        // ignore wobble smaller than this

int shown = -1;                     // last value we acted on

void setup() {
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int raw = analogRead(POT);         // 0..1023

  // A pot never quite reaches its ends. Snap the last 1% so the
  // LED actually goes fully off and fully on.
  if (raw < 10)   raw = 0;
  if (raw > 1013) raw = 1023;

  int level = raw >> 2;              // 1023 -> 255, cheaper than map()

  // Only react to real movement, or the LED flickers at rest
  if (shown < 0 || abs(level - shown) >= DEADBAND || level == 0 || level == 255) {
    shown = level;
    analogWrite(LED, level);
    Serial.print(F("level ")); Serial.println(level);
  }
}

Make it yours: apply the gamma curve from the PWM lab and compare. The knob will suddenly feel like a real dimmer rather than a switch with a vague middle.

Project 4 — Ultrasonic reversing sensor

New idea: timing an external signal with pulseIn(), and a beep whose rate encodes distance — all without blocking.

Parts: HC-SR04 (VCC→5V, GND→GND, Trig→D7, Echo→D6); passive buzzer on D8. Our HC-SR04 guide covers the sensor itself in depth.

04-reversing-sensor.ino
// Sound travels ~343 m/s, so 1 cm out-and-back takes ~58 us.
// The HC-SR04 gives an echo pulse whose width is that round trip.

const uint8_t TRIG = 7, ECHO = 6, BUZZER = 8;
const uint16_t MAX_CM = 200;
const uint32_t TIMEOUT_US = 25000UL;    // ~430 cm, past our range

uint32_t tPing = 0, tBeep = 0;
uint16_t distance = MAX_CM;

uint16_t readDistanceCm() {
  digitalWrite(TRIG, LOW);  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH); delayMicroseconds(10);   // datasheet trigger
  digitalWrite(TRIG, LOW);

  uint32_t us = pulseIn(ECHO, HIGH, TIMEOUT_US);
  if (us == 0) return MAX_CM;              // nothing came back
  uint16_t cm = us / 58;
  return (cm == 0 || cm > MAX_CM) ? MAX_CM : cm;
}

void setup() {
  pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); pinMode(BUZZER, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  uint32_t now = millis();

  // Ping 10x/second. Faster than that and echoes from the previous
  // ping are still bouncing around the room.
  if (now - tPing >= 100) {
    tPing = now;
    distance = readDistanceCm();
    Serial.print(distance); Serial.println(F(" cm"));
  }

  // Closer object -> shorter gap between beeps. Under 15 cm, solid tone.
  uint16_t gap = (distance >= MAX_CM) ? 0
                 : (distance < 15)      ? 1
                 : map(distance, 15, MAX_CM, 60, 900);

  if (gap == 0) { noTone(BUZZER); }
  else if (gap == 1) { tone(BUZZER, 2200); }        // continuous
  else if (now - tBeep >= gap) { tBeep = now; tone(BUZZER, 1800, 35); }
}
Arduino Uno5VGNDD7D6HC-SR04TRVCCTrigEchoGND5 VGNDTrig ← D7Echo → D6what happens on each ping10 µs triggerecho pulse — its width is the round tripcm = µs / 58
Four wires and one division. Trig and Echo are separate pins — the sensor never shares a line for both.

Make it yours: add three LEDs for green / amber / red zones. pulseIn() is the only blocking call left — and at 25 ms worst case it is worth knowing it is there.

Project 5 — Serial command console

New idea: parsing text commands from the Serial Monitor into a fixed char buffer — no String, no heap, no fragmentation.

Parts: LED on pin 9, and the USB cable you already have. Type on, off, set 128 or status into the Monitor.

05-serial-console.ino
const uint8_t LED = 9;
const uint8_t BUF = 24;

char    line[BUF];
uint8_t len = 0;
uint8_t level = 0;

void handle(char* cmd) {
  if      (strcmp(cmd, "on")  == 0) { level = 255; }
  else if (strcmp(cmd, "off") == 0) { level = 0; }
  else if (strncmp(cmd, "set ", 4) == 0) {
    int v = atoi(cmd + 4);
    level = constrain(v, 0, 255);          // never trust input
  }
  else if (strcmp(cmd, "status") == 0) {
    Serial.print(F("level=")); Serial.print(level);
    Serial.print(F(" uptime=")); Serial.print(millis() / 1000);
    Serial.println(F("s"));
    return;
  }
  else {
    Serial.print(F("? ")); Serial.println(cmd);
    Serial.println(F("try: on | off | set 0-255 | status"));
    return;
  }
  analogWrite(LED, level);
  Serial.print(F("ok level=")); Serial.println(level);
}

void setup() {
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
  Serial.println(F("ready. commands: on, off, set N, status"));
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();

    if (c == '\n' || c == '\r') {
      if (len) { line[len] = '\0'; handle(line); len = 0; }
    }
    else if (len < BUF - 1) {
      line[len++] = c;                     // overflow simply ignored
    }
  }
  // loop() stays free for everything else
}

Make it yours: add a save command that writes level to EEPROM, and read it back in setup(). Your brightness now survives a power cut.

Project 6 — Min/max logger that survives power loss

New idea: EEPROM done responsibly — EEPROM.update() instead of write(), and writes rate-limited so you never burn through the 100,000-cycle endurance.

Parts: any analog sensor or a potentiometer on A0. Optional SSD1306 OLED on A4/A5.

06-minmax-logger.ino
#include <EEPROM.h>

const uint8_t SENSOR = A0;
const int     ADDR_MAGIC = 0, ADDR_MIN = 2, ADDR_MAX = 4;
const uint8_t MAGIC = 0x5A;              // marks EEPROM as "ours"
const uint32_t SAVE_EVERY_MS = 60000UL;  // at most once a minute

int      vMin = 1023, vMax = 0;
uint32_t tSave = 0, tRead = 0;
bool     dirty = false;

void loadOrInit() {
  // A fresh ATmega reads 0xFF everywhere. Without a magic byte you
  // would load 65535 as your minimum and never recover.
  if (EEPROM.read(ADDR_MAGIC) != MAGIC) {
    EEPROM.update(ADDR_MAGIC, MAGIC);
    EEPROM.put(ADDR_MIN, vMin);
    EEPROM.put(ADDR_MAX, vMax);
    Serial.println(F("EEPROM initialised"));
    return;
  }
  EEPROM.get(ADDR_MIN, vMin);
  EEPROM.get(ADDR_MAX, vMax);
  Serial.print(F("restored min=")); Serial.print(vMin);
  Serial.print(F(" max="));        Serial.println(vMax);
}

void setup() {
  Serial.begin(9600);
  loadOrInit();
}

void loop() {
  uint32_t now = millis();

  if (now - tRead >= 200) {
    tRead = now;
    int v = analogRead(SENSOR);
    if (v < vMin) { vMin = v; dirty = true; }
    if (v > vMax) { vMax = v; dirty = true; }
    Serial.print(v);
    Serial.print(F("  min ")); Serial.print(vMin);
    Serial.print(F("  max ")); Serial.println(vMax);
  }

  // Only touch EEPROM when something changed, and never more than
  // once a minute. update() skips the write if the byte already matches.
  if (dirty && now - tSave >= SAVE_EVERY_MS) {
    tSave = now; dirty = false;
    EEPROM.put(ADDR_MIN, vMin);
    EEPROM.put(ADDR_MAX, vMax);
    Serial.println(F("saved"));
  }
}

// Endurance maths: one save per minute = 1,440/day. At 100,000 cycles
// that cell lasts ~69 days of continuous running. Rate-limit harder,
// or rotate across several addresses, for anything long-lived.

Make it yours: this is the natural capstone shape — sense, decide, store, report. Swap A0 for a real sensor, add the OLED, and you have a finished instrument.

14 · Hard-won

Twelve things that will waste your evening

None of these are in the datasheet. All of them have cost somebody a weekend.

Official boardATmega16U2ATMEGA16U2Driver ships with the OS.It is a full microcontrollerwith its own 16 KB of flash.Clone boardCH340GCH340GNeeds the CH340 driverinstalled before any portappears. Not a fault.
Same job, different silicon. This is the first thing to check when no port appears in the IDE.
01

Your clone needs a different driver

Official boards use the ATmega16U2. Cheap clones use a CH340 or CP2102. No port appears in the IDE until you install that chip’s driver — it is not a broken board.

02

Pin 13 lies to you as an input

The on-board LED and its resistor hang off pin 13 permanently, pulling it toward ground. Used as INPUT it reads unreliably, and INPUT_PULLUP fights the resistor. Never put a button on pin 13.

03

A6 and A7 do not exist here

They are on the Nano, not the Uno. The DIP-28 package has no legs for them. Code using A6 compiles and returns noise.

04

Servos must not be powered from the 5 V pin

A small SG90 pulls 100–250 mA while turning and over 500 mA stalled. On USB power it browns the board out mid-sweep, which looks exactly like a code bug. Separate 5 V supply, grounds tied together.

05

Opening the Serial Monitor restarts your sketch

DTR toggling resets the board. Counters zero, setup() reruns. Expected behaviour, endlessly confusing.

06

String will crash your sketch eventually

Repeated concatenation fragments 2 KB of heap until an allocation fails. The symptom is a board that works for twenty minutes then freezes. Use char arrays and snprintf.

07

Floating inputs read whatever they like

An INPUT pin with nothing attached is an antenna picking up mains hum. It will report phantom presses. Always INPUT_PULLUP or an external resistor.

08

The Servo library kills PWM on 9 and 10

It commandeers Timer1. analogWrite() on those pins stops working the moment you attach a servo, with no warning.

09

The 3.3 V pin gives you 50 mA, total

It comes from a tiny LDO, not the main regulator. An ESP-01 or a hungry radio module will crash the board the instant it transmits.

10

int is 16 bits, so it overflows at 32,767

int x = 200 * 200; gives you −25,536. Multiplying millis values, counting beyond 32k, or summing ADC readings all need long or uint32_t.

11

Grounds must be common

Two power supplies with unjoined grounds means your signals have no shared reference. Sensors read nonsense and nothing in the code will fix it. Tie every GND together.

12

12 V into the jack makes the regulator a heater

Linear regulation burns the difference. At 12 V and 400 mA that is 2.8 W in a part the size of a grain of rice. Use 7.5–9 V and it runs cool.

15 · Diagnosis

Something is wrong. Let’s narrow it down.

Answer the questions. Every path ends in a specific fix, not “check your wiring”.

Interactive

Fix-it tree

Twenty-two endings covering the failures that account for most support requests.

16 · Check yourself

Ten questions that separate copying from understanding

Each answer comes with the reasoning. Getting one wrong is more useful than getting it right.

Quiz

Arduino Uno fundamentals

No sign-in, no score kept. Just you and the silicon.

Question 1 of 10
17 · Vocabulary

The words, in plain language

Sketch
An Arduino program. A .ino text file containing C++ that gets compiled and flashed onto the chip.
Bootloader
A small program living in the top 512 bytes of flash. On reset it listens briefly for a new sketch over serial, then hands control to your code. It is why you can program an Uno with just a USB cable instead of a hardware programmer.
Sourcing and sinking current
Sourcing is a pin set HIGH pushing current out to a load that returns to GND. Sinking is a pin set LOW accepting current from a load connected to 5 V. The ATmega328P handles both at 20 mA per pin.
Pull-up and pull-down resistor
A resistor that gives a floating input a default state. A pull-up (to 5 V) makes the idle reading HIGH; a pull-down (to GND) makes it LOW. The Uno has pull-ups built in — use INPUT_PULLUP.
Duty cycle
The fraction of each PWM period that the output is HIGH, expressed as a percentage. analogWrite(0) is 0%, analogWrite(255) is 100%, analogWrite(128) is roughly 50%.
Volatile
A keyword telling the compiler a variable can change outside normal program flow — typically inside an interrupt. Without it, the compiler may cache the value in a register and never notice updates.
Shield
A board that stacks onto the Uno’s headers, matching its exact pin layout — motor drivers, Ethernet, displays, prototyping boards. The Uno’s 68.6 × 53.4 mm footprint is the de facto standard.
ICSP
In-Circuit Serial Programming. The 2×3 pin header that lets a hardware programmer write flash directly, bypassing the bootloader — used to recover a board whose bootloader is damaged, or to reclaim those 512 bytes.
Brownout
A supply voltage sag below what the chip needs to run correctly. It causes resets, corrupted readings and frozen loops — and it looks identical to a software bug, which is why it wastes so much time.
18 · FAQ

Questions people actually ask

Is the Arduino Uno still worth learning in 2026?
Yes, for learning specifically. Its limits are the lesson: 2 KB of SRAM forces you to think about memory, no Wi-Fi stack means your timing is your own, and 5 V logic means almost every hobby sensor plugs straight in. Once those habits are formed, moving to an ESP32 or an Uno R4 is a weekend. Starting on a 240 MHz board with 520 KB of RAM teaches none of it.
What is the difference between Arduino Uno R3 and R4?
The R4 keeps the shape, the 5 V logic and the pin positions, and changes everything inside: a 48 MHz 32-bit Renesas RA4M1 instead of the 16 MHz 8-bit ATmega328P, 256 KB of flash instead of 32 KB, 32 KB of SRAM instead of 2 KB, a 14-bit ADC instead of 10-bit, a real 12-bit DAC, USB-C, and a 6–24 V jack. The R4 WiFi adds Wi-Fi and Bluetooth LE plus a 12×8 LED matrix. Your existing sketches and shields mostly just work; code that pokes AVR registers directly does not.
How many LEDs can an Arduino Uno drive?
Directly, about nine or ten. Each needs its own pin and resistor at roughly 20 mA, and the chip’s total I/O budget is 200 mA. For more, switch to multiplexing, a shift register such as the 74HC595, a dedicated driver like the TLC5940, or addressable LEDs — but power addressable strips from their own supply, since each pixel at full white draws 60 mA.
Can the Arduino Uno run two programs at once?
No. One sketch, one loop(), no operating system. What you can do is make that loop handle several jobs by never blocking it — the timestamp pattern in the timing section runs as many independent timed tasks as you like on one core.
Why does my Arduino Uno say “port not found” or “access denied”?
Four causes, in order of likelihood: a clone board needing CH340 or CP2102 drivers; a charge-only USB cable with no data lines; the Serial Monitor of another IDE window holding the port open; or, on Linux, your user not being in the dialout group. The fix-it tree walks through each.
How much current can an Arduino Uno pin supply?
20 mA is the recommended continuous figure per pin and 40 mA the absolute maximum, with 200 mA across all pins combined. The 3.3 V pin is separately limited to 50 mA. Anything above that needs a transistor, a MOSFET or a driver board — the pin switches the load, it does not carry it.
Can I power an Arduino Uno from a 9 V battery?
Electrically yes, through the barrel jack or VIN. Practically it is a poor choice: a 9 V alkaline holds about 500 mAh, and the linear regulator throws away 44% of that as heat, so a basic sketch runs for a few hours. Four AA cells in series (6 V, ~2000 mAh) or a USB power bank into the USB socket both last far longer.
Why does my sketch work on USB but not on battery?
Almost always brownout. A battery’s voltage sags under load where a USB port holds steady, so the regulator’s output dips below what the chip needs and it resets or misbehaves. Measure the 5 V pin while the fault happens — if it reads under 4.5 V, the problem is power, not code.
What is the maximum sketch size on an Uno?
32,256 bytes — 32 KB of flash minus the 512-byte bootloader. Flash is rarely what you run out of, though: floating-point maths, pow(), sprintf with %f, and large libraries each cost 1–2 KB. SRAM runs out first, nearly every time.
Do I need to learn C++ before using an Arduino?
No. Start with the sketches here, change the numbers, see what happens, then change the structure. You will absorb variables, functions, conditionals and loops by needing them. Formal C++ — classes, templates, pointers — becomes interesting later, when you want to write your own library.
Next step

Reading about it only gets you so far

Our free self-paced Arduino Uno Fundamentals course takes you from this page to a working project of your own, with module quizzes and a certificate once your capstone is approved. If you would rather have someone looking over your shoulder, the 20-day live programme runs with daily assignments and review.

Written and maintained by eARgle Innovation Labs — IoT and embedded systems education.
Technical figures follow the ATmega328P datasheet and the official Arduino Uno R3 and R4 specifications. Last reviewed October 2026.
Found an error? Tell us and we will fix it, with credit.

Leave a Reply

Your email address will not be published. Required fields are marked *