All pinouts

Arduino AVR

Arduino Mega 2560 Pinout

The Arduino Mega 2560 uses an ATmega2560 to give you 54 digital I/O pins (15 PWM), 16 analog inputs, 4 hardware serial ports, and 8 KB of SRAM — the go-to board when an Uno runs out of pins or memory. Shield-compatible with the Uno footprint.

Specifications

MCU
ATmega2560, 16 MHz
Flash
256 KB (8 KB used by bootloader)
SRAM
8 KB
EEPROM
4 KB
Digital I/O
54 (15 PWM)
Analog inputs
16 (10-bit ADC)
Operating voltage
5V (7–12V on VIN)

Pin reference

PinNameType / functionsNotes
D0–D1Serial0 RX/TXUSB serialUsed by Serial — avoid for I/O.
D2–D13Digital I/ODigital, PWM on D2–D13
D14–D15Serial3 TX/RXUART3
D16–D17Serial2 TX/RXUART2
D18–D19Serial1 TX/RXUART1, INT5/INT4
D20SDAI2C SDA
D21SCLI2C SCL
D22–D53Digital I/OGeneral digital
D50MISOSPI MISO
D51MOSISPI MOSI
D52SCKSPI SCK
D53SSSPI SS (must be OUTPUT for master mode)
A0–A15Analog 0–15Analog input / Digital I/O
AREFAnalog referenceADC reference
VINVINPower input, 7–12V
5V5V outputRegulated 5V, ~800 mA
3V33.3V outputRegulated 3.3V, ~50 mA
GNDGroundPower
RESETResetPull LOW to reset

Gotchas

  • 01SPI pins are on D50–D53 — NOT on D11–D13 like the Uno. Most shields that hardcode D11–D13 for SPI will not work on the Mega.
  • 02I2C is on D20 (SDA) and D21 (SCL), not A4/A5.
  • 03Six hardware interrupts on D2, D3, D18, D19, D20, D21 (attachInterrupt).
  • 043.3V rail is weak (~50 mA) — power 3.3V modules from an external regulator.

Explain code for this board

Paste a sketch and get a plain-English breakdown.

Open code explainer

Generate a wiring diagram

Describe your circuit and get a Mermaid diagram you can share.

Open diagram generator

Other boards