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
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
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. | Pin | Signals | Status |
|---|---|---|---|
| 1 | IOREF | Tells a shield the board's logic voltage (5 V). | |
| 2 | RESET | Pull low to restart the ATmega2560. | |
| 3 | 3.3V | 3.3 V supply for low-voltage modules. I/O logic stays at 5 V. | |
| 4 | 5V | The regulated 5 V rail. | |
| 5 | GND | Ground | |
| 6 | GND | Ground | |
| 7 | VIN | Input voltage, the same input as the power jack. |
ANALOG A0–A7 · left side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | A0 | D54 | OK |
| 2 | A1 | D55 | OK |
| 3 | A2 | D56 | OK |
| 4 | A3 | D57 | OK |
| 5 | A4 | D58 | OK |
| 6 | A5 | D59 | OK |
| 7 | A6 | D60 | OK |
| 8 | A7 | D61 | OK |
ANALOG A8–A15 · left side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | A8 | D62 | OK |
| 2 | A9 | D63 | OK |
| 3 | A10 | D64 | OK |
| 4 | A11 | D65 | OK |
| 5 | A12 | D66 | OK |
| 6 | A13 | D67 | OK |
| 7 | A14 | D68 | OK |
| 8 | A15 | D69 | OK |
DIGITAL 8–13 · right side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | SCL | I2C clock, the same signal as D21, repeated for shields. | |
| 2 | SDA | I2C data, the same signal as D20, repeated for shields. | |
| 3 | AREF | External analog reference. Apply 0 to 5 V only. | |
| 4 | GND | Ground | |
| 5 | D13 | PWM, LED_BUILTIN | Caution |
| 6 | D12 | PWM | OK |
| 7 | D11 | PWM | OK |
| 8 | D10 | PWM | OK |
| 9 | D9 | PWM | OK |
| 10 | D8 | PWM | OK |
DIGITAL 0–7 · right side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | D7 | PWM | OK |
| 2 | D6 | PWM | OK |
| 3 | D5 | PWM | OK |
| 4 | D4 | PWM | OK |
| 5 | D3 | PWM | OK |
| 6 | D2 | PWM | OK |
| 7 | D1 | TX0 | Caution |
| 8 | D0 | RX0 | Caution |
COMMUNICATION 14–21 · right side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | D14 | TX3 | OK |
| 2 | D15 | RX3 | OK |
| 3 | D16 | TX2 | OK |
| 4 | D17 | RX2 | OK |
| 5 | D18 | TX1 | OK |
| 6 | D19 | RX1 | OK |
| 7 | D20 | SDA | Caution |
| 8 | D21 | SCL | Caution |
DOUBLE ROW 22–53 · bottom side
| No. | Pin | Signals | Status |
|---|---|---|---|
| 1 | 5V | 5 V on the double header. | |
| 2 | 5V | 5 V on the double header. | |
| 3 | D22 | — | OK |
| 4 | D23 | — | OK |
| 5 | D24 | — | OK |
| 6 | D25 | — | OK |
| 7 | D26 | — | OK |
| 8 | D27 | — | OK |
| 9 | D28 | — | OK |
| 10 | D29 | — | OK |
| 11 | D30 | — | OK |
| 12 | D31 | — | OK |
| 13 | D32 | — | OK |
| 14 | D33 | — | OK |
| 15 | D34 | — | OK |
| 16 | D35 | — | OK |
| 17 | D36 | — | OK |
| 18 | D37 | — | OK |
| 19 | D38 | — | OK |
| 20 | D39 | — | OK |
| 21 | D40 | — | OK |
| 22 | D41 | — | OK |
| 23 | D42 | — | OK |
| 24 | D43 | — | OK |
| 25 | D44 | PWM | OK |
| 26 | D45 | PWM | OK |
| 27 | D46 | PWM | OK |
| 28 | D47 | — | OK |
| 29 | D48 | — | OK |
| 30 | D49 | — | OK |
| 31 | D50 | MISO | OK |
| 32 | D51 | MOSI | OK |
| 33 | D52 | SCK | OK |
| 34 | D53 | SS | OK |
| 35 | GND | Ground | |
| 36 | GND | Ground |
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
Plug in with a USB-B cable
The power LED lights and your computer sees a new serial port.
- 2
Pick the board and port
Tools → Board → Arduino AVR Boards → Arduino Mega or Mega 2560Then choose the port under Tools → Port.
- 3
Upload Blink
arduino-cli compile --upload -p <port> --fqbn arduino:avr:mega BlinkThe L LED on D13 starts blinking.
- 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.
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.
More From This Board
6More Arduino Mega 2560 guides worth reading.

How to Build an Amateur Radio Telegraph Practice Oscillator (And Learn Morse Code the Way Hams Actually Do)
16m
Arduino Uno Ek R4: What Indian Buyers Should Know
10m
Arduino PWM Tutorial: analogWrite, LED Dimming, Motor Speed and Frequency
6mArduino Nano RP2040 Connect Pinout: D0–D13, A0–A7 and the NINA Pins
7m
Arduino Nano ESP32 Pinout: D/A Pins to ESP32-S3 GPIO, Power and Numbering Modes
7m
Arduino UNO R4 Minima vs WiFi: Which One Is Worth Buying?
10m