The following list shows the assignment of the connections of the ATmega 328P according to the designations in the Arduino IDE when compiling code for the Arduino Uno. You need this information if you want to use the controller as a single chip in your own circuit.
Arduino | ATmega328P | Pin | Pin | ATmega328P | Arduino |
---|---|---|---|---|---|
Reset | PC6 | 1 | 28 | PC5 (SCL) | A5 |
0 | PD0 (RX) | 2 | 27 | PC4 (SDA) | A4 |
1 | PD1 (TX) | 3 | 26 | PC3 | A3 |
2 | PD2 (INT0) | 4 | 25 | PC2 | A2 |
3 (PWM) | PD3 (INT1) | 5 | 24 | PC1 | A1 |
4 | PD4 | 6 | 23 | PC0 | A0 |
VCC | VCC | 7 | 22 | GND | GND |
GND | GND | 8 | 21 | AREF | AREF |
– | PB6 (XTAL1) | 9 | 20 | AVCC | AVCC |
– | PB7 (XTAL2) | 10 | 19 | PB5 (SCK) | 13 (LED) |
5 (PWM) | PD5 | 11 | 18 | PB4 (MISO) | 12 |
6 (PWM) | PD6 | 12 | 17 | PB3 (MOSI / OC2) | 11 (PWM) |
7 | PD7 | 13 | 16 | PB2 (SS / OC1B) | 10 (PWM) |
8 | PB0 | 14 | 15 | PB1 (OC1A) | 9 (PWM) |
Notes on the pin designations
The numbers 0-13 and A0-A5 can be used directly for functions like pinMode()
, digitalPinToInterrupt()
, digitalRead()
, digitalWrite()
. Pins 0-13 are only digital conections while A0-A5 can also be used as constants for the analog inputs for analogRead()
.
The connections which are indicated with PWM can be used to output a PWM signal with analogWrite()
. LED is the pin which is connected to the test LED of the Arduino can also addressed with the constant LED_BUILTIN.
Additional functions are:
- RESET: reset input.
- MISO: SPI master data input.
- MOSI: SPI master data output.
- SCK: SPI master clock input / SPI master clock input.
- SS: SPI slave select input.
- RX, TX: serial interface.
- SCL, SDA: I2C interface.
- INT: digital inputs which can trigger interrupts (
attachInterrupt()
). - XTAL: connections for an external crystal if the micro controller is clocked externally. On the Arduino a crystal with a frequency of 16 MHz is connected here.
- AREF: reference voltage for the analog inputs.
- AVCC: power supply for the A/D converters of the analog inputs.
- OC1A, OCA1B, OC2: output compare.