Digital and Analog Pins
Tables F-1 and F-2 show the digital and analog pins for the Arduino Uno board and the Mega board. The “Arduino” column is for the ATmega168/328, and the “Mega” column is for the ATmega1280/2560.
The Port column lists the physical port used for the pin—see Recipe 18.11 for information on how to set a pin by writing directly to a port. The introduction to Chapter 18 contains more details on timer usage. The table shows:
-
USART RX is hardware serial receive
-
USART TX is hardware serial transmit
-
Ext Int is external interrupt (followed by the interrupt number)
-
PWM TnA/B is the Pulse Width Modulation (
analogWrite) output on timer n -
MISO, MOSI, SCK, and SS are SPI control signals
-
SDA and SCL are I2C control signals
| Arduino 168/328 | Arduino Mega (pins 0–19) | |||||
|---|---|---|---|---|---|---|
| Digital pin | Port | Analog pin | Usage | Port | Analog pin | Usage |
|
0 |
PD 0 |
USART RX |
PE 0 |
USART0 RX, Pin Int 8 |
||
|
1 |
PD 1 |
USART TX |
PE 1 |
USART0 TX |
||
|
2 |
PD 2 |
Ext Int 0 |
PE 4 |
PWM T3B, INT4 |
||
|
3 |
PD 3 |
PWM T2B, Ext Int 1 |
PE 5 |
PWM T3C, INT5 |
||
|
4 |
PD 4 |
PG 5 |
PWM T0B |
|||
|
5 |
PD 5 |
PWM T0B |
PE 3 |
PWM T3A |
||
|
6 |
PD 6 |
PWM T0A |
PH 3 |
PWM T4A |
||
|
7 |
PD 7 |
PH 4 |
PWM T4B |
|||
|
8 |
PB 0 |
Input capture |
PH 5 |
PWM T4C |
||
|
9 |
PB 1 |
PWM T1A |
PH 6 |
PWM T2B |
||
|
10 |
PB 2 |
PWM T1B, SS |
PB 4 |
PWM T2A, Pin Int 4 |
||
|
11 |
PB 3 |
PWM T2A, MOSI |
PB 5 |
|||