Opens in a new tab

ATmega328P Pinout (DIP-28)

ATmega328P is the 8-bit AVR microcontroller behind the Arduino Uno and Nano. In the DIP-28 package it suits custom boards and breadboards – add a 16 MHz crystal and two capacitors and you have a “breadboard Arduino”.

The ATmega8, ATmega88 and ATmega168 share the same pin layout.

Specifications

  • 8-bit AVR up to 20 MHz (16 MHz on Arduino), 8 MHz internal oscillator
  • 32 kB flash, 2 kB SRAM, 1 kB EEPROM
  • 23 GPIO, 6 channels of 10-bit ADC (8 on TQFP and QFN packages)
  • UART, SPI, I2C (TWI), 3 timers, 6× PWM
  • 1.8–5.5 V supply (3.8 V and up at 16 MHz, 4.5 V and up at 20 MHz)

It is programmed over ISP (MOSI, MISO, SCK and RESET) – with a USBasp programmer or another Arduino running the ArduinoISP sketch. Once a bootloader is flashed, a USB-serial converter on RX and TX is all you need.

Pinout and pin table

Hover over a pin in the diagram or a table row; use the filter to highlight a bus. You can download the pinout as PNG or SVG.

Pin names:
ATmega328P – pinout (DIP-28)ATmega328P – pinout (DIP-28)chiptron.eu · CC BY 4.0ATmega328PDIP-28 1 PC6 RESET 2 PD0 D0 RX 3 PD1 D1 TX 4 PD2 D2 INT0 5 PD3 D3 PWM INT1 6 PD4 D4 7 VCC → Power 1.8–5.5 V (16 MHz from 3.8 V, 20 MHz from 4.5 V) 8 GND 9 PB6 XTAL1 10 PB7 XTAL2 11 PD5 D5 PWM 12 PD6 D6 PWM 13 PD7 D7 14 PB0 D8 28 PC5 A5 SCL ADC5 27 PC4 A4 SDA ADC4 26 PC3 A3 ADC3 25 PC2 A2 ADC2 24 PC1 A1 ADC1 23 PC0 A0 ADC0 22 GND 21 AREF ← A/D converter reference 20 AVCC ← A/D converter power – connect to VCC 19 PB5 D13 SCK 18 PB4 D12 MISO 17 PB3 D11 MOSI PWM 16 PB2 D10 SS PWM 15 PB1 D9 PWM GPIO Arduino UART I2C SPI ADC (analog) PWM Power Ground (GND) Control / reset
Download:PNGSVG
Pin table – ATmega328P (DIP-28)
PinNameArduinoDirectionUARTI2CSPIPWMADCNote
1PC6input/outputReset (active low) – usable as GPIO only after programming the RSTDISBL fuse, but then ISP programming no longer works
2PD0D0input/outputRXUART RX
3PD1D1input/outputTXUART TX
4PD2D2input/outputExternal interrupt INT0
5PD3D3input/outputPWMExternal interrupt INT1; PWM from Timer 2 (OC2B)
6PD4D4input/outputCounter T0 input
7VCCinputPower 1.8–5.5 V (16 MHz from 3.8 V, 20 MHz from 4.5 V)
8GND–
9PB6input/outputCrystal (XTAL1) – not free with an external crystal
10PB7input/outputCrystal (XTAL2) – not free with an external crystal
11PD5D5input/outputPWMPWM from timer 0 (OC0B); counter input T1
12PD6D6input/outputPWMPWM from timer 0 (OC0A); analog comparator AIN0
13PD7D7input/outputAnalog comparator AIN1
14PB0D8input/outputTimer 1 input capture (ICP1); clock output CLKO
15PB1D9input/outputPWMPWM from timer 1 (OC1A)
16PB2D10input/outputSSPWMPWM from timer 1 (OC1B); SPI SS
17PB3D11input/outputMOSIPWMPWM from timer 2 (OC2A); SPI MOSI (ISP)
18PB4D12input/outputMISOSPI MISO (ISP)
19PB5D13input/outputSCKSPI SCK (ISP); v Arduinu D13 s LED
20AVCCinputPower for the A/D converter and pins PC0–PC3 (PC4–PC6 are powered by VCC) – connect to VCC, ideally through an LC filter (10 µH + 100 nF).
21AREFinputA/D converter reference
22GND–
23PC0A0input/outputADC0
24PC1A1input/outputADC1
25PC2A2input/outputADC2
26PC3A3input/outputADC3
27PC4A4input/outputSDAADC4I2C SDA
28PC5A5input/outputSCLADC5I2C SCL

What to watch out for

  • Pin 1 (PC6) is RESET and needs a pull-up (10 kΩ). It can only be used as GPIO after programming the RSTDISBL fuse – but then the chip can no longer be programmed over ISP.
  • With an external crystal, PB6 and PB7 are taken.
  • Connect AVCC to VCC even if you don’t use the ADC, and add a 100 nF decoupling capacitor to every supply pin.
  • From the factory the chip runs at 1 MHz (the internal 8 MHz divided by 8) – without setting the fuses, Arduino timing will be off.
  • Double-check fuse settings – choosing the wrong clock source “bricks” the chip.

ATmega328P projects on chiptron.eu/

Projects and guides on chiptron.eu/:

  • LGT8F328P – an improved ATmega328P clone with a DAC and a higher clock, plus an overview of boards

More pinouts

See all pinouts on the Pinouts page.

Related Articles