Simvik

Arduino Uno pinout

The Arduino Uno (ATmega328P) pinout: what each pin does, from GPIO, analog inputs and PWM to UART, I2C and SPI, with the notes that catch people out.

The board

  • Microcontroller: ATmega328P, 8-bit AVR
  • Clock: 16 MHz
  • Flash: 32 KB (0.5 KB is the bootloader)
  • SRAM / EEPROM: 2 KB / 1 KB
  • Logic level: 5 V
  • Digital pins: 14 (D0–D13), 6 with PWM
  • Analog inputs: 6 (A0–A5), 10-bit: 0–1023
  • Serial: Serial on D0 (RX) and D1 (TX), shared with USB
  • I2C (Wire): SDA A4, SCL A5 (also on the SDA/SCL pins by AREF)
  • SPI: SS D10, MOSI D11, MISO D12, SCK D13
  • External interrupts: D2 (INT0), D3 (INT1)
  • On-board LED: D13 (LED_BUILTIN)

Pins

PinFunctionsNotes
0D0, PD0, RXSerial receive, wired to the USB serial chip.
1D1, PD1, TXSerial transmit, wired to the USB serial chip.
2D2, PD2, INT0External interrupt INT0: attachInterrupt(digitalPinToInterrupt(2), handler, mode).
3D3, PD3, ~PWM, OC2B, INT1analogWrite() PWM from Timer2 (OC2B), about 490 Hz. External interrupt INT1: attachInterrupt(digitalPinToInterrupt(3), handler, mode).
4D4, PD4
5D5, PD5, ~PWM, OC0BanalogWrite() PWM from Timer0 (OC0B), about 980 Hz.
6D6, PD6, ~PWM, OC0AanalogWrite() PWM from Timer0 (OC0A), about 980 Hz.
7D7, PD7
8D8, PB0
9D9, PB1, ~PWM, OC1AanalogWrite() PWM from Timer1 (OC1A), about 490 Hz.
10D10, PB2, ~PWM, OC1B, SSanalogWrite() PWM from Timer1 (OC1B), about 490 Hz. SPI SS: keep it an output while the board is the SPI controller, or SPI stops.
11D11, PB3, ~PWM, OC2A, MOSIanalogWrite() PWM from Timer2 (OC2A), about 490 Hz. Hardware SPI MOSI for the SPI library.
12D12, PB4, MISOHardware SPI MISO for the SPI library.
13D13, PB5, SCK, LEDHardware SPI SCK for the SPI library. Drives the on-board LED (LED_BUILTIN).
A0A0, PC0, ADC0Analog input: analogRead(A0) reads ADC channel 0. Also a digital pin: pinMode(A0, OUTPUT) and digitalWrite(A0, HIGH) work.
A1A1, PC1, ADC1Analog input: analogRead(A1) reads ADC channel 1. Also a digital pin: pinMode(A1, OUTPUT) and digitalWrite(A1, HIGH) work.
A2A2, PC2, ADC2Analog input: analogRead(A2) reads ADC channel 2. Also a digital pin: pinMode(A2, OUTPUT) and digitalWrite(A2, HIGH) work.
A3A3, PC3, ADC3Analog input: analogRead(A3) reads ADC channel 3. Also a digital pin: pinMode(A3, OUTPUT) and digitalWrite(A3, HIGH) work.
A4A4, PC4, ADC4, SDAAnalog input: analogRead(A4) reads ADC channel 4. Also a digital pin: pinMode(A4, OUTPUT) and digitalWrite(A4, HIGH) work. I2C SDA for the Wire library.
A5A5, PC5, ADC5, SCLAnalog input: analogRead(A5) reads ADC channel 5. Also a digital pin: pinMode(A5, OUTPUT) and digitalWrite(A5, HIGH) work. I2C SCL for the Wire library.
GNDGNDGround (0 V).
GNDGNDGround (0 V).
GNDGNDGround (0 V).
5V5V5 V supply: from USB, or from the regulator when the board is powered through VIN.
IOREFIOREFTells shields the I/O voltage of the board (5 V). Not a supply to draw from.
3.3V3V33.3 V supply from the on-board regulator. Keep the load small.

Good to know

  • Each I/O pin can source or sink about 20 mA (40 mA is the absolute maximum); keep the whole chip under 200 mA.
  • analogWrite() works on the pins marked ~PWM: about 490 Hz, or 980 Hz on the Timer0 pins. Timer0 also runs millis() and delay().
  • attachInterrupt() works on D2 and D3 only; every pin can raise a pin-change interrupt through the PCINT registers.
  • D0 and D1 carry Serial to the computer. Leave them free while you use the Serial Monitor.
  • The port tags give the register bit behind each pin: D13 is PB5, so PORTB |= (1 << PB5) drives it high without digitalWrite().