Skip to content

Guide

Ultimate Arduino Mega 2560 Pinout Guide: Complete Power & I/O Reference

Master the Arduino Mega 2560 pinout. Detailed reference for all 54 digital pins, 16 analog inputs, PWM, UARTs, SPI, I2C, interrupts, and power. Includes a printable table and practical wiring tips.

  • 12 min read
  • Updated November 21, 2026
Ultimate Arduino Mega 2560 Pinout Guide: Complete Power & I/O Reference

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.

Arduino Mega 2560 pinout diagram
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

Every side-header pin on the SolderHub Simulator Mega, colour-coded: green is free I/O, orange needs care (shared with USB serial or the board), red is power, grey is ground, blue is reset and reference pins. The 22–53 double header sits at the far end.

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.

What's on an Arduino Mega 2560: USB-B, reset button, regulator, jack, ATmega16U2, LEDs, the 0–21 and 22–53 headers, ICSP, crystal and the ATmega2560, labelled on the SolderHub Simulator Mega
What the Mega gives you (Uno figures in the notes)
Digital I/O pins
54

Uno: 14

Analog inputs
16

Uno: 6

PWM outputs
15

Uno: 6

External interrupts
6

Uno: 2

Hardware UARTs
4

Uno: 1

SRAM (KB)
8

Uno: 2 KB, so bigger buffers and more libraries fit

Counts from Arduino's Mega 2560 Rev3 and Uno R3 documentation.

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.

Power, ground and reset pins
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

PinWhat it does
VINExternal input, 7–12 V recommended (6–20 V accepted). Also reads the jack voltage.
5VRegulated 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.3V3.3 V output, 50 mA maximum.
GNDFive pins: two on the power header, one by AREF, two at the end of the double header. All one net.
IOREFTells shields the logic level: 5 V.
RESETPull 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.

Digital pins 0–21 on the side headers
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

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.

Digital pins D22–D53 on the double header. 5V is next to D22/D23 and GND is next to D52/D53 (Arduino, CC BY-SA 4.0)

💡 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).

PWM pins on the side headers (44–46 are on the double header)
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

sketch.ino
analogWrite(9, 128);   // about 50% duty cycle
TimerPWM pinsClaimed by
Timer04, 13millis() / delay(), so leave it alone
Timer111, 12Servo, after 12 servos
Timer29, 10tone()
Timer32, 3, 5Servo, after 24 servos
Timer46, 7, 8Servo, after 36 servos
Timer544, 45, 46Servo, 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.

Chart: the 15 Mega 2560 PWM pins grouped by Timer0 to Timer5, with PWM frequency and which library (Servo, tone()) claims each timer

Interrupt Pins (2, 3, 18, 19, 20, 21)

Six pins work with attachInterrupt(), three times the Uno's two.

External interrupt pins
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

sketch.ino
attachInterrupt(digitalPinToInterrupt(18), onPulse, FALLING);

Always use digitalPinToInterrupt(). On the Mega the raw numbers don't match the pins:

Pin2321201918
Interrupt number012345

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.

UART pins: Serial (0/1), Serial3 (14/15), Serial2 (16/17), Serial1 (18/19)
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

PortTXRX
Serial (USB)10
Serial11819
Serial21617
Serial31415
sketch.ino
Serial.begin(115200);    // USB, for debugging
Serial1.begin(9600);     // e.g. a GPS on 18/19
Serial1.println("Hello from Serial1");
Wiring diagram: a GPS module on Serial1 (pins 18/19) and an HC-05 on Serial2 (pins 16/17), with USB Serial still free for the Serial Monitor

💡 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.

SPI pins 50–53 (on the double header)
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

PinSPI signal
50CIPO (MISO)
51COPI (MOSI)
52SCK
53SS, keep it an OUTPUT
sketch.ino
#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.

I2C pins: 20/21 and the duplicated SDA/SCL by AREF
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

An SSD1306 OLED on the Mega's I2C pins: SDA to 20, SCL to 21, power from the double header's 5V and the GND by AREF (SolderHub Simulator parts)
sketch.ino
#include <Wire.h>
Wire.begin();                    // uses pins 20 and 21 automatically
Wire.beginTransmission(0x3C);    // a common OLED address

Breakouts 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.

Analog inputs A0–A15
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

sketch.ino
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.

AREF
IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Highlighted on the SolderHub Simulator Arduino Mega 2560 Rev3. Explore every pin on the Arduino Mega 2560 Rev3 board page.

sketch.ino
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.

Flowchart: which Mega 2560 pins to use for serial modules, SoftwareSerial, I2C, SPI, encoders, PWM, analog sensors and plain digital I/O
Interactive Mega pinout: tap any pin

85 of 85 pins match

IOREFRESET3.3V5VGNDGNDVINA0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15SCLSDAAREFGNDD13D12D11D10D9D8D7D6D5D4D3D2D1D0D14D15D16D17D18D19D20D21

Hover or tap any pin on the board

ANALOG A0–A7 header · pin 1

A0

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
Tap or hover any pin for its functions and warnings.

Complete Pin Table

Interrupt numbers are the ones attachInterrupt() uses.

PinPortFunctions
0PE0Serial RX (USB)
1PE1Serial TX (USB)
2PE4PWM (Timer3), interrupt 0
3PE5PWM (Timer3), interrupt 1
4PG5PWM (Timer0, ~980 Hz)
5PE3PWM (Timer3)
6PH3PWM (Timer4)
7PH4PWM (Timer4)
8PH5PWM (Timer4)
9PH6PWM (Timer2)
10PB4PWM (Timer2), PCINT4
11PB5PWM (Timer1), PCINT5
12PB6PWM (Timer1), PCINT6
13PB7PWM (Timer0, ~980 Hz), L LED, PCINT7
14PJ1Serial3 TX, PCINT10
15PJ0Serial3 RX, PCINT9
16PH1Serial2 TX
17PH0Serial2 RX
18PD3Serial1 TX, interrupt 5
19PD2Serial1 RX, interrupt 4
20PD1I2C SDA, interrupt 3
21PD0I2C SCL, interrupt 2
22–29PA0–PA7Digital I/O (5V at the 22/23 end)
30–37PC7–PC0Digital I/O
38PD7Digital I/O
39–41PG2–PG0Digital I/O
42–43PL7–PL6Digital I/O
44–46PL5–PL3PWM (Timer5)
47–49PL2–PL0Digital I/O
50PB3SPI CIPO, PCINT3
51PB2SPI COPI, PCINT2
52PB1SPI SCK, PCINT1
53PB0SPI SS, PCINT0 (GND at the 52/53 end)
A0–A7 (54–61)PF0–PF7ADC0–ADC7
A8–A15 (62–69)PK0–PK7ADC8–ADC15, PCINT16–23
Arduino's official Mega 2560 Rev3 pinout: power, digital, analog, PWM timers, interrupts and serial pins (Arduino, CC BY-SA 4.0)

Five Mega Mistakes to Avoid

  1. Uno I2C wiring on A4/A5. The Mega's I2C is on 20/21.
  2. Uno SPI wiring on 10–13. The Mega's SPI is on 50–53 and the ICSP header.
  3. Raw interrupt numbers. attachInterrupt(2, …) means pin 21. Use digitalPinToInterrupt().
  4. 3.3 V devices on 5 V outputs. Level-shift every line the Mega drives into a 3.3 V-only input.
  5. 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.

Continue learning

Related articles

All articles

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.