Arduino Mega Reference
The ATmega2560-based board — same programming model as the Uno, with far more I/O: 54 digital
pins, 16 analog inputs, and 4 hardware serial ports.
Pin names
| Pin ID | Label | Signal | Notes |
|---|
0 | D0 / RX0 | USART | Serial 0 receive (shared with USB) |
1 | D1 / TX0 | USART | Serial 0 transmit (shared with USB) |
2–13 | D2–D13 | PWM | All support analogWrite(); D13 has the built-in LED |
14 / 15 | D14/RX3, D15/TX3 | USART | Serial 3 |
16 / 17 | D16/RX2, D17/TX2 | USART | Serial 2 |
18 / 19 | D18/RX1, D19/TX1 | USART | Serial 1 |
20 | D20 / SDA | I²C | I²C data |
21 | D21 / SCL | I²C | I²C clock |
22–43 | D22–D43 | Digital | General-purpose I/O |
44–46 | D44–D46 | PWM | analogWrite() |
47–49 | D47–D49 | Digital | General-purpose I/O |
50 | D50 / MISO | SPI | SPI data in |
51 | D51 / MOSI | SPI | SPI data out |
52 | D52 / SCK | SPI | SPI clock |
53 | D53 / SS | SPI | SPI slave select |
| Pin ID | Label | Signal | Notes |
|---|
IOREF | IOREF | — | Board operating voltage reference |
RESET | RESET | — | Pull LOW to reset the board |
3.3V | 3.3V | Power | 3.3 V output |
5V | 5V | Power | 5 V output |
GND | GND | Power | Ground (multiple pins) |
VIN | VIN | Power | External power input (7–12 V) |
A0–A15 | A0–A15 | Analog | analogRead(), 10-bit (0–1023) |
Quick reference
| Capability | Pins |
|---|
| Digital I/O | D0–D53 (54 pins) |
| Analog input | A0–A15 (16 pins, 10-bit) |
| PWM output | D2–D13, D44–D46 |
| SPI | D50 (MISO), D51 (MOSI), D52 (SCK), D53 (SS) |
| I²C | D20 (SDA), D21 (SCL) |
| USART | 4 ports: Serial (D0/D1), Serial1 (D18/D19), Serial2 (D16/D17), Serial3 (D14/D15) |
| Operating voltage | 5 V |
| Clock speed | 16 MHz |
Usage
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600); // USB serial (D0/D1)
Serial1.begin(9600); // second hardware serial (D18/D19)
}
void loop() {
digitalWrite(13, HIGH);
int val = analogRead(A0);
Serial.println(val);
delay(500);
}
Reach for the Mega over the Uno when a project needs more I/O than the Uno's 14 digital / 6
analog pins provide, or needs more than one hardware serial port at once (e.g. talking to a
GPS module on Serial1 while debugging over USB Serial).
See also