Skip to content
Board reference

Arduino Mega 2560

More pins, more memory

Arduino Mega 2560 Rev3 (A000067) · ATmega2560 + ATmega16U2

The UNO's big brother for projects that run out of pins: an ATmega2560 at 16 MHz with 54 digital pins (15 PWM), 16 analog inputs, four hardware serial ports and 256 kB of flash, all at 5 V logic.

Tested in the SolderHub Simulator. Opens a ready-wired circuit that runs in your browser.

Digital I/O
54
PWM / Analog in
15 / 16
Serial ports
4
Flash / SRAM
256 kB / 8 kB

Every header pin at a glance

  • 65 safe I/O
  • 5 use with care
  • 0 avoid
  • 0 not available
  • 15 power, ground & other

01Pinout

Every pin, live

Power and analog on the left, the digital and communication headers on the right, the 36-pin double row at the bottom. Hover or 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
Full header tables (POWER, ANALOG A0–A7, ANALOG A8–A15, DIGITAL 8–13, DIGITAL 0–7, COMMUNICATION 14–21, DOUBLE ROW 22–53)

POWER · left side

No.PinSignalsStatus
1IOREFTells a shield the board's logic voltage (5 V).
2RESETPull low to restart the ATmega2560.
33.3V3.3 V supply for low-voltage modules. I/O logic stays at 5 V.
45VThe regulated 5 V rail.
5GNDGround
6GNDGround
7VINInput voltage, the same input as the power jack.

ANALOG A0–A7 · left side

No.PinSignalsStatus
1A0D54OK
2A1D55OK
3A2D56OK
4A3D57OK
5A4D58OK
6A5D59OK
7A6D60OK
8A7D61OK

ANALOG A8–A15 · left side

No.PinSignalsStatus
1A8D62OK
2A9D63OK
3A10D64OK
4A11D65OK
5A12D66OK
6A13D67OK
7A14D68OK
8A15D69OK

DIGITAL 8–13 · right side

No.PinSignalsStatus
1SCLI2C clock, the same signal as D21, repeated for shields.
2SDAI2C data, the same signal as D20, repeated for shields.
3AREFExternal analog reference. Apply 0 to 5 V only.
4GNDGround
5D13PWM, LED_BUILTINCaution
6D12PWMOK
7D11PWMOK
8D10PWMOK
9D9PWMOK
10D8PWMOK

DIGITAL 0–7 · right side

No.PinSignalsStatus
1D7PWMOK
2D6PWMOK
3D5PWMOK
4D4PWMOK
5D3PWMOK
6D2PWMOK
7D1TX0Caution
8D0RX0Caution

COMMUNICATION 14–21 · right side

No.PinSignalsStatus
1D14TX3OK
2D15RX3OK
3D16TX2OK
4D17RX2OK
5D18TX1OK
6D19RX1OK
7D20SDACaution
8D21SCLCaution

DOUBLE ROW 22–53 · bottom side

No.PinSignalsStatus
15V5 V on the double header.
25V5 V on the double header.
3D22—OK
4D23—OK
5D24—OK
6D25—OK
7D26—OK
8D27—OK
9D28—OK
10D29—OK
11D30—OK
12D31—OK
13D32—OK
14D33—OK
15D34—OK
16D35—OK
17D36—OK
18D37—OK
19D38—OK
20D39—OK
21D40—OK
22D41—OK
23D42—OK
24D43—OK
25D44PWMOK
26D45PWMOK
27D46PWMOK
28D47—OK
29D48—OK
30D49—OK
31D50MISOOK
32D51MOSIOK
33D52SCKOK
34D53SSOK
35GNDGround
36GNDGround

02Safety

Pins to avoid, and why

No boot-strapping pins. Five pins are shared with something on the board.

Use with care

5 pins

Usable, but shared with the USB link, the on-board LED or the I2C pull-ups.

  • D0Shared with USB. D0 and D1 (Serial) go to the ATmega16U2 USB bridge. Anything wired here can garble the serial monitor and make uploads fail. Use Serial1–3 on D14–D19 for other serial devices.
  • D1Shared with USB. D0 and D1 (Serial) go to the ATmega16U2 USB bridge. Anything wired here can garble the serial monitor and make uploads fail. Use Serial1–3 on D14–D19 for other serial devices.
  • D13On-board LED. The L LED is wired to D13 (LED_BUILTIN), so it lights whenever the pin is high. Fine for outputs; pick another pin for a sensitive input.
  • D20I2C with fixed pull-ups. D20 and D21 are the I2C bus and have external pull-up resistors that cannot be disabled, so they read high when nothing drives them and can't be used as interrupts while I2C is in use.
  • D21I2C with fixed pull-ups. D20 and D21 are the I2C bus and have external pull-up resistors that cannot be disabled, so they read high when nothing drives them and can't be used as interrupts while I2C is in use.

03Layout

How the board fits together

USB-B → ATmega16U2

USB-to-serial bridge for uploads and Serial

Power jack / VIN

Into the 5 V linear regulator

ATmega2560

8-bit AVR · 16 MHz · 256 kB flash · 8 kB SRAM

Digital D0–D53

15 PWM, SPI on D50–D53, 6 interrupts

Analog A0–A15

10-bit ADC

4 serial ports

Serial on USB, Serial1–3 on D14–D19

04Specs

Full specifications

Microcontroller

Chip
Microchip ATmega25608-bit AVR
Clock
16 MHz
Flash
256 kB8 kB of it holds the bootloader.
SRAM
8 kB
EEPROM
4 kB

Power

Logic level
5 V
USB input
4.8 to 5.5 V
Other inputs
Power jack or VINThrough the on-board 5 V linear regulator.

Analog

Inputs
16 (A0 to A15)
Resolution
10-bit0 to 1023 across 0 to 5 V.
References
5 V, 1.1 V, 2.56 V, AREFINTERNAL1V1 and INTERNAL2V56 on the Mega; AREF 0 to 5 V only.

Peripherals

PWM
15 pins: D2–D13, D44–D46About 490 Hz; 980 Hz on D4 and D13.
Serial
4 UARTsSerial on D0/D1 (USB), Serial1 D19/D18, Serial2 D17/D16, Serial3 D15/D14.
SPI / I2C
SPI on D50–D53, I2C on D20/D21
Interrupts
D2, D3, D18, D19, D20, D21

Board

USB
USB-B
USB bridge
ATmega16U2
Programming
USB bootloader or ICSP

05Buses

Where each bus lives

Serial ports

Serial: D0/D1, shared with USB. Serial1: RX1 D19, TX1 D18. Serial2: RX2 D17, TX2 D16. Serial3: RX3 D15, TX3 D14. Serial1–3 are not connected to the USB bridge.

I2C (Wire)

SDA on D20, SCL on D21, repeated on the SDA/SCL pins next to AREF. Fixed external pull-ups.

SPI

CIPO (MISO) D50, COPI (MOSI) D51, SCK D52, SS D53, also on the ICSP header. Not on D10–D13 like the UNO.

PWM (analogWrite)

D2–D13 and D44–D46. D4 and D13 run at about 980 Hz, the rest at about 490 Hz.

External interrupts

D2, D3, D18, D19, D20 and D21 through digitalPinToInterrupt(). D20/D21 only when I2C is not in use.

06Power & start

Power it up and get connected

Power options

  • USB-B4.8 to 5.5 V from your computer. Also uploads and the serial monitor.
  • Power jack / VINExternal supply, regulated to 5 V by the on-board linear regulator.
  • 5V and 3.3V pinsOutputs for sensors and modules; more 5V and GND pins sit on the double row.
  1. 1

    Plug in with a USB-B cable

    The power LED lights and your computer sees a new serial port.

  2. 2

    Pick the board and port

    Tools → Board → Arduino AVR Boards → Arduino Mega or Mega 2560

    Then choose the port under Tools → Port.

  3. 3

    Upload Blink

    arduino-cli compile --upload -p <port> --fqbn arduino:avr:mega Blink

    The L LED on D13 starts blinking.

  4. 4

    No board on your desk?

    Open the tested Mega circuit in the SolderHub Simulator below.

07Gotchas

Things that trip people up

01

SPI moved to D50–D53

UNO shields and tutorials that expect SPI on D10–D13 won't work as wired. Use D50 (CIPO), D51 (COPI), D52 (SCK) and D53 (SS), or the ICSP header.

02

Use Serial1–3, not D0/D1

D0/D1 are the USB serial port. GPS modules, Bluetooth adapters and other serial parts belong on Serial1 (D19/D18), Serial2 (D17/D16) or Serial3 (D15/D14).

03

D20 and D21 always pull high

The I2C pins have external pull-ups that can't be turned off, so they read high on their own and can't serve as interrupts while I2C runs.

04

Servos only cost PWM past 12

On the Mega up to 12 servos leave PWM alone; servos 13–23 switch off PWM on D11 and D12.

05

I2C is not on A4/A5

Unlike the UNO, A4 and A5 are plain analog inputs on the Mega. Wire I2C to D20/D21 or the SDA/SCL pins by AREF.

08SolderHub Simulator

Wire up the Arduino Mega 2560 without the hardware

The simulator runs Arduino Mega 2560 sketches in your browser. Start from the tested board circuit, then change the wiring or the code.

Board Basics

Introduction, pinout, and protocols — all in one guide.

Board basics guide coming soon

Sensor Modules & Library

Wiring sensors and modules, plus the library you need to talk to them.

Sensor Integration

Coming soon

Library & Setup

Coming soon

SolderHub Simulator

Arduino Mega 2560 circuits you can run in the browser

Ready-wired circuits with working code. Open one, press run, then change the wiring or the sketch.

Tested on Arduino Mega 2560