ATmega328P DIP-28 – Pinout Diagram & Arduino Pin Reference

Complete pinout diagram for the Atmel/Microchip ATmega328P DIP-28 AVR microcontroller along with Arduino pin references.
Featured image for ATmega328P DIP-28 pin diagram and Arduino pin reference from CIRCUITSTATE Electronics
ATmega328P DIP-28 pinout diagram

ATmega328P is an 8-bit microcontroller from the AVR family. It was initially designed Atmel which is now part of Microchip. The ATmega328P became popular after being used for the first microcontroller board from Arduino, the Arduino Uno. On this page, you will find beautiful pinout diagrams designed by CIRCUITSTATE and the pin reference for the Arduino framework.

Specifications

CPU Speed (MIPS/DMIPS)20 (at 20 MHz)
Program Memory TypeFlash
Program Memory Size32 KB
SRAM2 KB
Data EEPROM1 KB
8 Bit Digital Timers2
16-bit Timers1
PWM Channels6
GPIOs23
ADC Channels8
Max ADC Resolution10 Bits
Number of Comparators1
SPI2 (1 shared with USART)
USART1
I2C1
Temp. Range-40 to 85 °C
Operating Voltage Range1.8 – 5.5 V
Sleep Modes6 (Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and Extended Standby)
Pin Count28

We can develop embedded firmware for you

CIRCUITSTATE can develop embedded firmware for any microcontroller/microprocessor including 8051, PIC, AVR, ARM, STM32, ESP32, and RISC-V using industry-leading SDKs, frameworks, and tools. Contact us today to share your requirements.

Electronics Networking Vector Image

Pinout Diagram

Latest Revision: r0.5, 08-01-2023
Design by: Vishnu Mohanan
License: CC-BY-SA 4.0

Pinouts are based on the latest documentation from the manufacturer. While we try our best to be accurate and up-to-date here, we can not guarantee correctness. Please also double-check the pin assignments with that from the official documentation. If you found any errors here, please let us know in the comments. We will update our designs ASAP.

PNG

Vector pinout diagram of ATmega328P 28-DIP microcontroller revision 0.5 from CIRCUITSTATE Electronics
Click for higher resolution

Even though only Arduino digital pins are shown, all other peripheral pins have the same functions in the Arduino environment.

PDF

PDF preview may not load on mobile devices. Click the link to open an interactive preview, or download it directly.

Pin Reference

Power & Control

VCC & GND

These are the main supply pins. All GND pins should be connected together. VCC supply can range from 1.8V to 5.5V. Changing the voltage will also change the maximum clock frequency the microcontroller can run reliably. Check the datasheet for more info.

XTAL

XTAL1 and XTAL2 are the pins for providing external clock signals to the microcontroller. A crystal oscillator can be connected to these pins along with capacitors. The fuses also need to be configured to select an external oscillator. If you have an external clock source, it can be connected to XTAL1 while leaving XTAL2 floating. Both pins have IO functions, but those functions can be not used while the pins are used for clock input. See “Alternate Functions of Port B” in the datasheet for more info.

AVCC

AVCC is the supply pin for the internal ADC of ATmega328P. This pin should be connected to VCC externally along with a filter capacitor, even if the ADC is not used. You could connect a low-noise supply to this pin, but in that case, the supply voltage must not differ from the VCC by more than ±0.3V.

AREF

The ATmega328P has two options for the ADC reference voltage; an internal reference of 1.1V (nominal) and AVCC supply. The AREF pin is used to decouple the ADC reference voltage for better noise performance.

RESET

RESET is an active-low external reset input for ATmega328P. This pin is usually pulled up with a 10K resistor and a 0.1uF capacitor connected to GND. A LOW pulse of 2.5 μs or longer can reset the MCU (without the capacitor). RESET also has GPIO function but it can only be used when the external reset function is disabled.

Arduino Pins

Below are Arduino pin assignments used for the official Arduino Uno board with an ATmega328P. If you are new to Arduino, we have a complete tutorial covering the basics of the Arduino development framework (ADF) using the popular Arduino Uno board.

Getting-Started-with-Arduino-Open-Source-Electronics-Prototyping-Platform-Arduino-UNO-CIRCUITSTATE-Electronics-Featured-Image-01-2

Getting Started with Arduino – Beginner’s Tutorial to Open-Source Hardware Prototyping with Arduino Uno

Learn electronics hardware prototyping and coding with the most popular Arduino open-source microcontroller platform. Learn how to write your first program and upload it to the Arduino Uno board.

GPIO

Even though ATmega328P has 23 GPIOs, only 20 are available in the Arduino framework. Some alternate function pins are excluded. All GPIO pins support internal pull-ups in the range of 20-50K.

Pin #Pin NameArduino Digital Pin
2PD00
3PD11
4PD22
5PD33
6PD44
11PD55
12PD66
13PD77
14PB08
15PB19
16PB210
17PB311
18PB412
19PB513
23PC014
24PC115
25PC216
26PC317
27PC418
28PC519

LED

Arduino Uno has an onboard LED for debugging. This LED is connected to digital pin 13. You can access the LED pin as LED_BUILTIN in the Arduino IDE.

UART

ATmega328P has only 1 UART and the TXD and RXD pins are connected to the USB-Serial chip on an Arduino Uno. If you need extra UART ports, you can consider using the SoftwareSerial library. Hardware flow control pins (CTS, RTS) are not available in the Arduino framework.

Pin #Digital PinFunctionArduino Instance
20TXDSerial
31RXDSerial

SPI

There are two SPI (Serial Peripheral Interface) ports available in ATmega328P but one is shared with the UART. So only one SPI interface is usable.

Pin #Digital PinFunctionArduino Instance
1711COPISPI
1812CIPOSPI
1913SCKSPI
1610CSSPI

I2C

There is only one I2C (Inter-Integrated Circuit) interface available in ATmega328P. The I2C pins also share ADC input functions. You can only use one function at a time. I2C is also called Wire in the Arduino environment.

Pin #Digital PinFunctionArduino Instance
2718SDAWire
2819SCLWire

ADC

ATmega328P has a single 10-bit ADC with 6 multiplexed channels. The maximum sampling rate is 15 ksps. There are two additional inputs AIN0 and AIN1 used for analog comparator inputs.

Pin #Digital PinArduino ADC Pin
2314A0
2415A1
2516A2
2617A3
2718A4
2819A5

PWM

The hardware timer blocks of ATmega328P can be used to generate PWM (Pulse Width Modulation) of varying duty cycles and frequencies. PWM output is supported by 6 pins in the Arduino environment, labeled as OCxx on the pinout diagram. You can use the analogWrite() function to output the PWM waveform. You can learn more about Arduino Uno PWM from – Secrets of Arduino PWM.

Pin #Digital PinFrequency (Hz)
53490
115980
126980
159490
1610490
1711490

External Interrupts

There are only two external interrupt pins available on ATmega328P called INT0 and INT1. These interrupts can detect FALLING, RISING, LOW or CHANGE triggers. But all GPIO ports also have common change interrupt capability. The change interrupt can be generated by any pins of a port, and such pins are labeled as PCINTxx on the pinout diagram.

Pin #Digital PinFunction
42INT0
53INT1
  1. ATmega328P Datasheet – Microchip [PDF]
  2. Getting Started with Arduino Uno – Tutorial
Share to your friends
Vishnu Mohanan

Vishnu Mohanan

Founder and CEO at CIRCUITSTATE Electronics

Articles: 84

Leave a Reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.