

The ATmega328 is a low-power, high-performance 8-bit microcontroller developed by Microchip (formerly Atmel). It is based on the AVR RISC architecture and is widely used in embedded systems, IoT devices, and hobbyist projects. The ATmega328 is particularly popular due to its integration in Arduino boards, such as the Arduino UNO.
Key features of the ATmega328 include 32 KB of flash memory, 2 KB of SRAM, 1 KB of EEPROM, and 23 general-purpose I/O pins. Its compact DIP-28 package makes it easy to use in breadboard and prototyping applications.








| Parameter | Value |
|---|---|
| Architecture | 8-bit AVR RISC |
| Operating Voltage | 1.8V - 5.5V |
| Flash Memory | 32 KB |
| SRAM | 2 KB |
| EEPROM | 1 KB |
| Clock Speed | Up to 20 MHz |
| I/O Pins | 23 |
| ADC Channels | 6 (10-bit resolution) |
| Timers | 3 (2x 8-bit, 1x 16-bit) |
| Communication Interfaces | UART, SPI, I²C (TWI) |
| Package | DIP-28 |
The ATmega328 in the DIP-28 package has 28 pins, each with specific functions. Below is the pinout description:
| Pin No. | Pin Name | Function Description |
|---|---|---|
| 1 | PC6 (RESET) | Reset input (active low) |
| 2 | PD0 (RXD) | UART Receive (Serial Communication) |
| 3 | PD1 (TXD) | UART Transmit (Serial Communication) |
| 4 | PD2 | Digital I/O, External Interrupt 0 (INT0) |
| 5 | PD3 | Digital I/O, External Interrupt 1 (INT1) |
| 6 | PD4 | Digital I/O |
| 7 | VCC | Power Supply (2.7V - 5.5V) |
| 8 | GND | Ground |
| 9 | PB6 (XTAL1) | External Oscillator Input |
| 10 | PB7 (XTAL2) | External Oscillator Output |
| 11 | PD5 | Digital I/O |
| 12 | PD6 | Digital I/O, PWM Output |
| 13 | PD7 | Digital I/O |
| 14 | PB0 | Digital I/O, PWM Output |
| 15 | PB1 | Digital I/O, PWM Output |
| 16 | PB2 | Digital I/O, PWM Output |
| 17 | PB3 | Digital I/O, SPI MOSI |
| 18 | PB4 | Digital I/O, SPI MISO |
| 19 | PB5 | Digital I/O, SPI SCK |
| 20 | AVCC | Analog Power Supply |
| 21 | AREF | Analog Reference Voltage |
| 22 | GND | Ground |
| 23 | PC0 (ADC0) | Analog Input Channel 0 |
| 24 | PC1 (ADC1) | Analog Input Channel 1 |
| 25 | PC2 (ADC2) | Analog Input Channel 2 |
| 26 | PC3 (ADC3) | Analog Input Channel 3 |
| 27 | PC4 (ADC4) | Analog Input Channel 4, I²C SDA |
| 28 | PC5 (ADC5) | Analog Input Channel 5, I²C SCL |
The ATmega328 is the microcontroller used in the Arduino UNO. Below is an example code to blink an LED connected to pin 13:
// Blink an LED connected to digital pin 13
void setup() {
pinMode(13, OUTPUT); // Set pin 13 as an output
}
void loop() {
digitalWrite(13, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(13, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}
Microcontroller Not Responding
Program Upload Fails
Analog Readings Are Inaccurate
External Oscillator Not Working
Q: Can I use the ATmega328 without an external crystal?
A: Yes, the ATmega328 has an internal 8 MHz oscillator, but it is less accurate than an external crystal.
Q: How do I reset the ATmega328?
A: Pull the RESET pin low momentarily to reset the microcontroller.
Q: What is the maximum current per I/O pin?
A: Each I/O pin can source or sink up to 40 mA, but it is recommended to limit it to 20 mA for safe operation.
Q: Can I use the ATmega328 with 3.3V systems?
A: Yes, the ATmega328 operates at 3.3V, but ensure the clock speed does not exceed 12 MHz at this voltage.
This concludes the documentation for the ATmega328 (DIP-28).