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 | Name | Arduino | Direction | UART | I2C | SPI | PWM | ADC | Note |
|---|---|---|---|---|---|---|---|---|---|
| 1 | PC6 | input/output | Reset (active low) – usable as GPIO only after programming the RSTDISBL fuse, but then ISP programming no longer works | ||||||
| 2 | PD0 | D0 | input/output | RX | UART RX | ||||
| 3 | PD1 | D1 | input/output | TX | UART TX | ||||
| 4 | PD2 | D2 | input/output | External interrupt INT0 | |||||
| 5 | PD3 | D3 | input/output | PWM | External interrupt INT1; PWM from Timer 2 (OC2B) | ||||
| 6 | PD4 | D4 | input/output | Counter T0 input | |||||
| 7 | VCC | input | Power 1.8–5.5 V (16 MHz from 3.8 V, 20 MHz from 4.5 V) | ||||||
| 8 | GND | – | |||||||
| 9 | PB6 | input/output | Crystal (XTAL1) – not free with an external crystal | ||||||
| 10 | PB7 | input/output | Crystal (XTAL2) – not free with an external crystal | ||||||
| 11 | PD5 | D5 | input/output | PWM | PWM from timer 0 (OC0B); counter input T1 | ||||
| 12 | PD6 | D6 | input/output | PWM | PWM from timer 0 (OC0A); analog comparator AIN0 | ||||
| 13 | PD7 | D7 | input/output | Analog comparator AIN1 | |||||
| 14 | PB0 | D8 | input/output | Timer 1 input capture (ICP1); clock output CLKO | |||||
| 15 | PB1 | D9 | input/output | PWM | PWM from timer 1 (OC1A) | ||||
| 16 | PB2 | D10 | input/output | SS | PWM | PWM from timer 1 (OC1B); SPI SS | |||
| 17 | PB3 | D11 | input/output | MOSI | PWM | PWM from timer 2 (OC2A); SPI MOSI (ISP) | |||
| 18 | PB4 | D12 | input/output | MISO | SPI MISO (ISP) | ||||
| 19 | PB5 | D13 | input/output | SCK | SPI SCK (ISP); v Arduinu D13 s LED | ||||
| 20 | AVCC | input | Power 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). | ||||||
| 21 | AREF | input | A/D converter reference | ||||||
| 22 | GND | – | |||||||
| 23 | PC0 | A0 | input/output | ADC0 | |||||
| 24 | PC1 | A1 | input/output | ADC1 | |||||
| 25 | PC2 | A2 | input/output | ADC2 | |||||
| 26 | PC3 | A3 | input/output | ADC3 | |||||
| 27 | PC4 | A4 | input/output | SDA | ADC4 | I2C SDA | |||
| 28 | PC5 | A5 | input/output | SCL | ADC5 | I2C 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.