The Arduino Mega 2560 is what you reach for when an Uno runs out of room. It's the same 5 V Arduino, with 54 digital pins, 16 analog inputs, 15 PWM outputs and four hardware serial ports. A CNC controller, a 3D printer, a robot arm or a project with a dozen sensors all fit comfortably.
Counting 86 header pins can feel intimidating at first, but they fall into a few clear groups. This guide takes them one group at a time, each highlighted on a real Mega drawing, and flags the spots where the Mega differs from the Uno. The big one: I2C lives on pins 20 and 21, not A4/A5.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
What's Actually on the Board
The Mega is built around the ATmega2560: 8-bit AVR, 16 MHz, 256 KB flash (8 KB used by the bootloader), 8 KB SRAM and 4 KB EEPROM. An ATmega16U2 handles USB. Many clones swap it for a CH340, which can need a driver.
Uno: 14
Uno: 6
Uno: 6
Uno: 2
Uno: 1
Uno: 2 KB, so bigger buffers and more libraries fit
Power Pins
The power header sits on the bottom edge. The 22–53 double header also carries 5V at its top end and GND at its bottom end, so modules plugged in there can be powered right where they sit.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
| Pin | What it does |
|---|---|
| VIN | External input, 7–12 V recommended (6–20 V accepted). Also reads the jack voltage. |
| 5V | Regulated 5 V. On USB it's limited by the port and the board's 500 mA fuse; on the jack, by how hot the regulator gets. |
| 3.3V | 3.3 V output, 50 mA maximum. |
| GND | Five pins: two on the power header, one by AREF, two at the end of the double header. All one net. |
| IOREF | Tells shields the logic level: 5 V. |
| RESET | Pull LOW to restart. |
⚠️ Warning
Servos, motors and LED strips should have their own 5 V supply with a shared GND, not the Mega's 5V pin.
Digital Pins 0–53
Every one of the 54 pins is an input or an output at 0 V or 5 V. Rated 20 mA per pin (40 mA absolute), with about 200 mA total across all I/O.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
The 22–53 double header. Even pins run down one row and odd pins down the other, in pairs: 22/23, 24/25 … 52/53. 5V is at the 22/23 end, GND at the 52/53 end. Double-check before plugging in, because swapping them puts 5V on ground.
💡 Tip
On the Mega Rev3 the L LED on pin 13 is buffered by an op-amp, so it doesn't load the pin. Pin 13 works as normal I/O; the LED just follows it.
PWM Pins (2–13 and 44–46)
Fifteen PWM outputs: pins 2–13 plus 44, 45 and 46. They run at about 490 Hz, except pins 4 and 13 at about 980 Hz (Timer0).
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
analogWrite(9, 128); // about 50% duty cycle| Timer | PWM pins | Claimed by |
|---|---|---|
| Timer0 | 4, 13 | millis() / delay(), so leave it alone |
| Timer1 | 11, 12 | Servo, after 12 servos |
| Timer2 | 9, 10 | tone() |
| Timer3 | 2, 3, 5 | Servo, after 24 servos |
| Timer4 | 6, 7, 8 | Servo, after 36 servos |
| Timer5 | 44, 45, 46 | Servo, first |
When a library grabs a timer, PWM stops on every pin of that timer. That's the most common "my PWM just stopped" report on the Mega.
Interrupt Pins (2, 3, 18, 19, 20, 21)
Six pins work with attachInterrupt(), three times the Uno's two.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
attachInterrupt(digitalPinToInterrupt(18), onPulse, FALLING);Always use digitalPinToInterrupt(). On the Mega the raw numbers don't match the pins:
| Pin | 2 | 3 | 21 | 20 | 19 | 18 |
|---|---|---|---|---|---|---|
| Interrupt number | 0 | 1 | 2 | 3 | 4 | 5 |
So an old attachInterrupt(2, isr, FALLING) listens on pin 21, not pin 2. Pins 20/21 are also I2C, and 18/19 are Serial1, so plan which job they do.
Pin-change interrupts cover 10–15, 50–53 and A8–A15. They also decide where SoftwareSerial can receive: its RX must be one of those pins, or it never gets a byte.
Serial Pins: Four Hardware UARTs
This is the Mega's best feature. You can talk to a GPS, a Bluetooth module and another board at the same time, and still keep the USB Serial Monitor for debugging.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
| Port | TX | RX |
|---|---|---|
| Serial (USB) | 1 | 0 |
| Serial1 | 18 | 19 |
| Serial2 | 16 | 17 |
| Serial3 | 14 | 15 |
Serial.begin(115200); // USB, for debugging
Serial1.begin(9600); // e.g. a GPS on 18/19
Serial1.println("Hello from Serial1");💡 Tip
Reaching for SoftwareSerial on a Mega? Use Serial1–3 instead. Hardware UARTs cost no CPU time and work at high baud rates.
SPI Pins (50–53)
SD cards, TFTs and radios. These are not on 10–13 like the Uno, so Uno SPI wiring has to move. The same signals are on the central ICSP header, which is how most SPI shields connect.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
| Pin | SPI signal |
|---|---|
| 50 | CIPO (MISO) |
| 51 | COPI (MOSI) |
| 52 | SCK |
| 53 | SS, keep it an OUTPUT |
#include <SPI.h>
pinMode(53, OUTPUT); // SS must be an output for the Mega to stay SPI controller
SPI.begin();I2C Pins (20 SDA, 21 SCL)
On the Mega, A4 and A5 are just analog pins. I2C is on 20 (SDA) and 21 (SCL), repeated as SDA/SCL next to AREF. Uno shields and wiring that use A4/A5 for I2C won't work here unless you rewire them.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
#include <Wire.h>
Wire.begin(); // uses pins 20 and 21 automatically
Wire.beginTransmission(0x3C); // a common OLED addressBreakouts usually include pull-ups. Bare chips need about 4.7 kΩ on each line, because the internal 20–50 kΩ pull-ups are too weak. Pins 20/21 are also external interrupts (Arduino numbers 3 and 2), so you can't use both jobs at once.
Analog Inputs (A0–A15)
Sixteen inputs on one 10-bit ADC: 0–1023 across 0–5 V, about 100 µs per reading. All of them also work as digital pins 54–69.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
int raw = analogRead(A8);
float volts = raw * (5.0 / 1023.0);- Keep the source impedance under about 10 kΩ. A high-resistance divider can't charge the ADC in time, and readings bleed from the previous channel. If you can't lower it, read twice and keep the second value.
- A floating input wanders randomly, so only trust pins with something connected.
- A8–A15 also support pin-change interrupts, which makes them handy SoftwareSerial RX pins.
AREF
Feed AREF a lower reference to get finer readings from small signals, after selecting it in code.
Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.
analogReference(EXTERNAL); // before any voltage reaches AREF
// analogReference(INTERNAL1V1); // built-in 1.1 V (INTERNAL2V56 gives 2.56 V)Which Pin Should I Use?
Follow the chart from the top for each part you add.
85 of 85 pins match
Hover or tap any pin on the board
ANALOG A0–A7 header · pin 1
A0
Safe to use
10-bit analog input. Also digital pin 54.
Nothing else on the board depends on this pin. A good first choice for sensors, LEDs and buttons.
Can be used as
- Analog in
Signals on this pad
- A0
- D54
Complete Pin Table
Interrupt numbers are the ones attachInterrupt() uses.
| Pin | Port | Functions |
|---|---|---|
| 0 | PE0 | Serial RX (USB) |
| 1 | PE1 | Serial TX (USB) |
| 2 | PE4 | PWM (Timer3), interrupt 0 |
| 3 | PE5 | PWM (Timer3), interrupt 1 |
| 4 | PG5 | PWM (Timer0, ~980 Hz) |
| 5 | PE3 | PWM (Timer3) |
| 6 | PH3 | PWM (Timer4) |
| 7 | PH4 | PWM (Timer4) |
| 8 | PH5 | PWM (Timer4) |
| 9 | PH6 | PWM (Timer2) |
| 10 | PB4 | PWM (Timer2), PCINT4 |
| 11 | PB5 | PWM (Timer1), PCINT5 |
| 12 | PB6 | PWM (Timer1), PCINT6 |
| 13 | PB7 | PWM (Timer0, ~980 Hz), L LED, PCINT7 |
| 14 | PJ1 | Serial3 TX, PCINT10 |
| 15 | PJ0 | Serial3 RX, PCINT9 |
| 16 | PH1 | Serial2 TX |
| 17 | PH0 | Serial2 RX |
| 18 | PD3 | Serial1 TX, interrupt 5 |
| 19 | PD2 | Serial1 RX, interrupt 4 |
| 20 | PD1 | I2C SDA, interrupt 3 |
| 21 | PD0 | I2C SCL, interrupt 2 |
| 22–29 | PA0–PA7 | Digital I/O (5V at the 22/23 end) |
| 30–37 | PC7–PC0 | Digital I/O |
| 38 | PD7 | Digital I/O |
| 39–41 | PG2–PG0 | Digital I/O |
| 42–43 | PL7–PL6 | Digital I/O |
| 44–46 | PL5–PL3 | PWM (Timer5) |
| 47–49 | PL2–PL0 | Digital I/O |
| 50 | PB3 | SPI CIPO, PCINT3 |
| 51 | PB2 | SPI COPI, PCINT2 |
| 52 | PB1 | SPI SCK, PCINT1 |
| 53 | PB0 | SPI SS, PCINT0 (GND at the 52/53 end) |
| A0–A7 (54–61) | PF0–PF7 | ADC0–ADC7 |
| A8–A15 (62–69) | PK0–PK7 | ADC8–ADC15, PCINT16–23 |
Five Mega Mistakes to Avoid
- Uno I2C wiring on A4/A5. The Mega's I2C is on 20/21.
- Uno SPI wiring on 10–13. The Mega's SPI is on 50–53 and the ICSP header.
- Raw interrupt numbers.
attachInterrupt(2, …)means pin 21. UsedigitalPinToInterrupt(). - 3.3 V devices on 5 V outputs. Level-shift every line the Mega drives into a 3.3 V-only input.
- Swapping the double header's ends. 5V is by 22/23, GND by 52/53.
No Mega on your desk? Wire any of these examples on the virtual Mega in the SolderHub Simulator. It's the same board as in these figures.
Quick Answers
How many pins does the Arduino Mega 2560 have? 54 digital (0–53) and 16 analog (A0–A15), plus power pins. Fifteen digital pins are PWM.
Which Mega pins are PWM? 2–13 and 44, 45, 46.
Which pins are I2C on the Mega? 20 (SDA) and 21 (SCL), repeated next to AREF. Not A4/A5.
Which pins are SPI on the Mega? 50 (CIPO), 51 (COPI), 52 (SCK) and 53 (SS), plus the ICSP header.
How many serial ports does the Mega have? Four: Serial (0/1, USB), Serial1 (18/19), Serial2 (16/17) and Serial3 (14/15).
Which end of the 22–53 header is 5V? The 22/23 end. GND is at the 52/53 end.
Why does my SoftwareSerial receive nothing? Its RX pin must support pin-change interrupts: 10–15, 50–53 or A8–A15. Better, use Serial1–3.
My clone Mega doesn't show up as a COM port. It probably uses a CH340 instead of the 16U2. Install the CH340 driver; the pinout is the same.
Keep Reading
The Arduino Uno R3 pinout and Nano pinout cover the smaller ATmega328P boards. The Mega vs Uno comparison helps you choose, and I2C vs SPI explains which bus to pick.
Official pinout images: Arduino Mega 2560 Rev3 by Arduino, CC BY-SA 4.0.



