Source: https://mokxi.com/learn/atmega328p-pinout
Updated: 2026-10-26

Learn

# ATmega328P pinout: every pin on the DIP, and its Arduino number

Beginner

Written by the Mokxi team, updated October 26, 2026

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The bare chip with 5 V on VCC and AVCC, a 10 k pull-up on RESET and an LED on PB5, pin 19, which is pin 13 in code.

This is the pinout of the ATmega328P in its 28-pin DIP, the chip in an Arduino Uno’s socket and the one people wire up as an "Arduino on a breadboard". Every pin is in the table below with the number a sketch uses for it, what it can do and what to watch for. After the table come the power pins and how to wire them, the crystal pins and the 8 MHz build that frees them, the reset pin, the pins a programmer uses, and the buses.

The circuit above is the bare chip in Mokxi, wired the way the tutorial wires it: 5 V on VCC and AVCC, both grounds, a 10 k pull-up on RESET, and an LED on PB5, which is pin 13 in code, running the Uno’s Blink. The table is read from the same chip model the simulator runs, and where the simulator does less than the chip, the page says so.

## Every pin on the chip

Hold the chip with its notch at the top. Pin 1 is top left, and the numbers run down the left side to pin 14, then up the right side from 15 to 28. The table goes in that order. The two GND pins, 8 and 22, share one row.

The names are the data sheet’s port names: PD0 is bit 0 of port D. A sketch uses the Uno’s numbers, because the chip runs the Uno’s core: PD0 to PD7 are 0 to 7, PB0 to PB5 are 8 to 13, and PC0 to PC5 are A0 to A5. So digitalWrite(13, HIGH) drives PB5, pin 19.

ATmega328P, 28-pin DIP: pin 1 to 28, notch at the top
Pin | Arduino pin | What it can do | Watch out for

RESET | - | Pin 1. Low resets the chip. | Hold it high with 10 k to 5 V. Not a GPIO.

PD0 | 0 | Pin 2. RX: Serial in. | Leave free if you upload through a USB serial adapter.

PD1 | 1 | Pin 3. TX: Serial out. | Leave free if you upload through a USB serial adapter.

PD2 | 2 | Pin 4. Digital. INT0: attachInterrupt. | A good first choice for a button.

PD3 | 3 | Pin 5. PWM on timer 2. INT1: attachInterrupt. | tone() takes timer 2 on a real chip.

PD4 | 4 | Pin 6. Digital. | -

VCC | - | Pin 7. The supply, in. | The chip runs only while this is on a supply.

GND | - | Pins 8 and 22. Ground. | Wire both.

XTAL1 | - | Pin 9. The crystal. PB6 on the 8 MHz build. | Not a GPIO on the 16 MHz build.

XTAL2 | - | Pin 10. The crystal. PB7 on the 8 MHz build. | Not a GPIO on the 16 MHz build.

PD5 | 5 | Pin 11. PWM on timer 0. | Timer 0 also runs millis().

PD6 | 6 | Pin 12. PWM on timer 0. | Timer 0 also runs millis().

PD7 | 7 | Pin 13. Digital. | -

PB0 | 8 | Pin 14. Digital. | -

PB1 | 9 | Pin 15. PWM on timer 1. | The Servo library takes timer 1 on a real chip.

PB2 | 10 | Pin 16. PWM on timer 1. SPI SS. | The Servo library takes timer 1 on a real chip.

PB3 | 11 | Pin 17. PWM on timer 2. SPI MOSI, and ISP MOSI. | A programmer uses it.

PB4 | 12 | Pin 18. Digital. SPI MISO, and ISP MISO. | A programmer uses it.

PB5 | 13 | Pin 19. Digital. SPI SCK, and ISP SCK. LED_BUILTIN. | There is no LED on the chip: wire one.

AVCC | - | Pin 20. The ADC’s supply, in. | Wire it to VCC. Not checked in Mokxi.

AREF | - | Pin 21. The analog reference. | Not a GPIO. Not checked in Mokxi.

PC0 | A0 | Pin 23. Analog. Digital 14. | -

PC1 | A1 | Pin 24. Analog. Digital 15. | -

PC2 | A2 | Pin 25. Analog. Digital 16. | -

PC3 | A3 | Pin 26. Analog. Digital 17. | -

PC4 | A4 | Pin 27. Analog. Digital 18. I2C SDA. | Used by any I2C device.

PC5 | A5 | Pin 28. Analog. Digital 19. I2C SCL. | Used by any I2C device.

## Power: VCC, AVCC and the two grounds

The chip is not a board, so it has no supply of its own. VCC, pin 7, powers the chip, and AVCC, pin 20, powers its ADC and port C. Wire both to 5 V, and wire both GND pins, 8 and 22, to ground. A missing ground or a missing VCC wire is the commonest reason a breadboard ATmega328P does nothing.

In Mokxi the chip runs only while VCC is wired to a supply of 1.8 V or more. Without one every pin lets go and nothing runs, as on the bench. Two things are simpler here than on a desk: the pins swing to 5 V whatever VCC is, so a chip on 3.3 V is not modeled as one, and AVCC and AREF are not checked, so analogRead reads against 5 V even if AVCC is left unwired. A real chip wants 4.5 V for 16 MHz; Mokxi does not check that either.

## The crystal pins, and the 8 MHz build

A chip with the Uno’s bootloader runs at 16 MHz from a crystal between pins 9 and 10, XTAL1 and XTAL2, with a 22 pF capacitor from each of those pins to ground. While the crystal is in use, those two pins are the oscillator’s and not port pins.

Mokxi has a second build of the chip that runs from its internal 8 MHz oscillator, with no crystal. On it pins 9 and 10 are PB6 and PB7, two more port pins, though the Uno’s core gives them no number, so reach them through PORTB. It runs code built for 8 MHz, the 3.3 V Pro Mini’s. A sketch built for 16 MHz runs at half speed on it, as on a real chip.

In Mokxi the crystal and its capacitors are not parts. The clock is the build’s whether or not a crystal is wired, and the internal oscillator’s few percent of error is not modeled: the 8 MHz is exact.

## RESET, and the pins a programmer uses

RESET, pin 1, restarts the chip when it is pulled low. The chip has a weak pull-up of its own; the tutorials add a 10 k resistor to 5 V so that noise cannot reset it, and a button from RESET to ground makes a reset button.

A bare chip has no USB, so a real one is programmed one of two ways. A programmer, such as a USBasp or an Uno running Arduino as ISP, uses PB3, PB4 and PB5 (pins 17, 18 and 19) for MOSI, MISO and SCK, and RESET to start. Or a chip with the Uno’s bootloader takes the ordinary Uno upload through a USB serial adapter on PD0 and PD1. The 8 MHz build needs its fuses set first: pick MiniCore’s ATmega328 with the internal 8 MHz clock and burn the bootloader once. Mokxi does not simulate fuses or the bootloader.

## PWM, analog, Serial, I2C and SPI

PWM is on Arduino pins 3, 5, 6, 9, 10 and 11, which are PD3, PD5, PD6, PB1, PB2 and PB3. 5 and 6 are timer 0, 9 and 10 are timer 1, and 3 and 11 are timer 2, as on the Uno. The analog inputs are PC0 to PC5, A0 to A5, ten bits, 0 to 1023. The DIP has no A6 or A7; those are on the Nano’s smaller package.

Serial is PD0 and PD1. I2C is PC4 for SDA and PC5 for SCL. SPI is PB2, PB3, PB4 and PB5 for SS, MOSI, MISO and SCK. In Mokxi Serial reaches the serial monitor directly, and both buses run in software on their pins, because the chip’s I2C and SPI blocks are not modeled.

## Questions

What is the minimum circuit for an ATmega328P on a breadboard?

VCC and AVCC to 5 V, both GND pins to ground, and a 10 k resistor from RESET to 5 V. A 16 MHz chip also needs its crystal on pins 9 and 10 with a 22 pF capacitor from each to ground. The 8 MHz internal clock needs no crystal.

Which ATmega328P pin is Arduino pin 13?

PB5, pin 19. It is also SPI SCK and `LED_BUILTIN`, but the bare chip has no LED: wire one with a 220 ohm resistor.

Which ATmega328P pins are PWM?

PD3, PD5, PD6, PB1, PB2 and PB3, which are pins 5, 11, 12, 15, 16 and 17 on the DIP, and 3, 5, 6, 9, 10 and 11 in code.

Which pins do I connect to program an ATmega328P?

For a programmer: MOSI to PB3 (pin 17), MISO to PB4 (pin 18), SCK to PB5 (pin 19), its reset line to RESET (pin 1), plus VCC and ground. For a chip with the Uno’s bootloader: a USB serial adapter on PD0 and PD1.

Do I need both GND pins and AVCC?

On a real chip, yes: wire both grounds, and AVCC to VCC even if you never use the ADC. Mokxi does not check AVCC, but wire it anyway so the circuit works on a desk.

Why does my ATmega328P do nothing?

Check the supply first. VCC must be wired to a supply, and both grounds to ground. In Mokxi a chip with nothing on VCC lets go of every pin and does not run.

Related

## Keep going

Arduino Uno Pinout: ATmega328P Pins, PWM, I2C, SPI Arduino Nano Pinout: PWM, I2C, SPI, A6 and A7 Pull-Up Resistors and the Floating Input They Fix Arduino stk500_getsync() Not in Sync: Upload Fixes How Many LEDs Can One Arduino Pin Drive? Run the ATmega328P on a breadboard in the simulator Help: the ATmega328P model The project page, with the full sketch Beginner

Sources

## Where the facts on this page come from

- Microchip: the ATmega328P and its datasheet (pins, supply, clock sources, ISP)
- Arduino: using an Arduino as an ISP programmer
- MCUdude: MiniCore, for the ATmega328 on its internal 8 MHz clock

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
