Tables F-1 and F-2 show the digital and analog pins for the Arduino Uno board and the Mega board.
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 |
PWM T1A, Pin Int 5 |
||
12 |
PB 4 |
SPI MISO |
PB 6 |
PWM T1B, Pin Int 6 |
||
13 |
PB 5 |
SPI SCK |
PB 7 |
PWM T0A, Pin Int 7 |
||
14 |
PC 0 |
0 |
PJ 1 |
USART3 TX, Pin Int 10 |
||
15 |
PC 1 |
1 |
PJ 0 |
USART3 RX, Pin Int 9 |
||
16 |
PC 2 |
2 |
PH 1 |
USART2 TX |
||
17 |
PC 3 |
3 |
PH 0 |
USART2 RX |
||
18 |
PC 4 |
4 |
I2C SDA |
PD 3 |
USART1 TX, Ext Int 3 |
|
19 |
PC 5 |
5 |
I2C SCL |
PD 2 |
USART1 RX, Ext Int 2 |
Arduino Mega (pins 20–44) | Arduino Mega (pins 45–69) | |||||
---|---|---|---|---|---|---|
Digital pin | Port | Usage | Digital pin | Port | Analog pin | Usage |
20 |
PD 1 |
I2C SDA, Ext Int 1 |
45 |
PL 4 |
PWM 5B |
|
21 |
PD 0 |
I2C SCL, Ext Int 0 |
46 |
PL 3 |
PWM 5A |
|
22 |
PA 0 |
Ext Memory addr bit 0 |
47 |
PL 2 |
T5 external counter |
|
23 |
PA 1 |
Ext Memory bit 1 |
48 |
PL 1 |
ICP T5 |
|
24 |
PA 2 |
Ext Memory bit 2 |
49 |
PL 0 |
ICP T4 |
|
25 |
PA 3 |
Ext Memory bit 3 |
50 |
PB 3 |
SPI MISO |
|
26 |
PA 4 |
Ext Memory bit 4 |
51 |
PB 2 |
SPI MOSI |
|
27 |
PA 5 |
Ext Memory bit 5 |
52 |
PB 1 |
SPI SCK |
|
28 |
PA 6 |
Ext Memory bit 6 |
53 |
PB 0 |
SPI SS |
|
29 |
PA 7 |
Ext Memory bit 7 |
54 |
PF 0 |
0 |
|
30 |
PC 7 |
Ext Memory bit 15 |
55 |
PF 1 |
1 |
|
31 |
PC 6 |
Ext Memory bit 14 |
56 |
PF 2 |
2 |
|
32 |
PC 5 |
Ext Memory bit 13 |
57 |
PF 3 |
3 |
|
33 |
PC 4 |
Ext Memory bit 12 |
58 |
PF 4 |
4 |
|
34 |
PC 3 |
Ext Memory bit 11 |
59 |
PF 5 |
5 |
|
35 |
PC 2 |
Ext Memory bit 10 |
60 |
PF 6 |
6 |
|
36 |
PC 1 |
Ext Memory bit 9 |
61 |
PF 7 |
7 |
|
37 |
PC 0 |
Ext Memory bit 8 |
62 |
PK 0 |
8 |
Pin Int 16 |
38 |
PD 7 |
63 |
PK 1 |
9 |
Pin int 17 |
|
39 |
PG 2 |
ALE Ext Mem |
64 |
PK 2 |
10 |
Pin Int 18 |
40 |
PG 1 |
RD Ext Mem |
65 |
PK 3 |
11 |
Pin Int 19 |
41 |
PG 0 |
Wr Ext Mem |
66 |
PK 4 |
12 |
Pin Int 20 |
42 |
PL 7 |
67 |
PK 5 |
13 |
Pin Int 21 |
|
43 |
PL 6 |
68 |
PK 6 |
14 |
Pin Int 22 |
|
44 |
PL 5 |
PWM 5C |
69 |
PK 7 |
15 |
Pin Int 23 |
Table F-3 is a summary of timer modes showing the pins used with popular Arduino chips.
Timer | Arduino 168/328 | Mega |
---|---|---|
Timer 0 mode (8-bit) |
Fast PWM |
Fast PWM |
Timer0A |
Pin 6 |
Pin 13 |
Timer0B |
Pin 5 |
Pin 4 |
Timer 1 (16-bit) |
Phase correct PWM |
Phase correct PWM |
Timer1A |
Pin 9 |
Pin 11 |
Timer1B |
Pin 10 |
Pin 12 |
Timer 2 (8-bit) |
Phase correct PWM |
Phase correct PWM |
Timer2A |
Pin 11 |
Pin 10 |
Timer2B |
Pin 3 |
Pin 9 |
Timer 3 (16-bit) |
N/A |
Phase correct PWM |
Timer3A |
Pin 5 |
|
Timer3B |
Pin 2 |
|
Timer3C |
Pin 3 |
|
Timer 4 (16-bit) |
N/A |
Phase correct PWM |
Timer4A |
Pin 6 |
|
Timer4B |
Pin 7 |
|
Timer4C |
Pin 8 |
|
Timer 5 (16-bit) |
N/A |
Phase correct PWM |
Timer5A |
Pin 46 |
|
Timer5B |
Pin 45 |
|
Timer5C |
Pin 44 |
Note that the Arduino column is for the ATmega 168/328, and the Mega column is for the ATmega 1280/2560.
Full details of the Arduino controller chips can be found in the datasheets:
The datasheet for standard boards (Atmega168/328) can be downloaded from http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf.
The mega (ATmega1280/2560) datasheet can be downloaded from http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf.
3.149.255.162