Arduino Mega 2560

An ATmega2560-based Arduino board with 54 digital I/O pins and 256 KB of flash for projects that outgrow the Uno.

Arduino Mega 2560: ATmega2560 · Expanded I/O

What is the Arduino Mega 2560?

The Arduino Mega 2560 is a microcontroller board built around Microchip's ATmega2560 running at 16 MHz. It exposes 54 digital I/O pins, 16 analog inputs, 256 KB of flash memory, 8 KB of SRAM, and 4 KB of EEPROM, giving it far more room for pins, code, and variables than the Uno. This makes it the default choice when a build needs to talk to dozens of sensors, drivers, or displays at once.

The board runs its logic at 5V and offers four hardware UARTs (serial ports), an SPI bus on pins D50 to D53, and an I2C bus on D20 (SDA) and D21 (SCL). Fifteen of the digital pins can output PWM. A separate ATmega16U2 handles the USB connection by acting as a USB-to-serial converter, so the board shows up as a COM port for uploading sketches and printing to the Serial Monitor.

The Mega keeps the Uno header footprint at one end, so most Uno shields still fit, while adding two long banks of extra headers along the board for large wiring harnesses. Makers reach for it in 3D printers, CNC controllers, home automation hubs, and any project where the pin count or memory of a smaller board runs out.

Arduino Mega 2560 pin reference

PinFunctionType
D0 D0 (RX0)UART RX · DigitalBidirectional (GPIO)
D1 D1 (TX0)UART TX · DigitalBidirectional (GPIO)
D2 D2 (PWM)PWM · DigitalBidirectional (GPIO)
D3 D3 (PWM)PWM · DigitalBidirectional (GPIO)
D4 D4 (PWM)PWM · DigitalBidirectional (GPIO)
D5 D5 (PWM)PWM · DigitalBidirectional (GPIO)
D6 D6 (PWM)PWM · DigitalBidirectional (GPIO)
D7 D7 (PWM)PWM · DigitalBidirectional (GPIO)
D8 D8 (PWM)PWM · DigitalBidirectional (GPIO)
D9 D9 (PWM)PWM · DigitalBidirectional (GPIO)
D10 D10 (PWM)PWM · DigitalBidirectional (GPIO)
D11 D11 (PWM)PWM · DigitalBidirectional (GPIO)
D12 D12 (PWM)PWM · DigitalBidirectional (GPIO)
D13 D13 (LED)PWM · DigitalBidirectional (GPIO)
D14 D14 (TX3)UART TX3 · DigitalBidirectional (GPIO)
D15 D15 (RX3)UART RX3 · DigitalBidirectional (GPIO)
D16 D16 (TX2)UART TX2 · DigitalBidirectional (GPIO)
D17 D17 (RX2)UART RX2 · DigitalBidirectional (GPIO)
D18 D18 (TX1)UART TX1 · DigitalBidirectional (GPIO)
D19 D19 (RX1)UART RX1 · DigitalBidirectional (GPIO)
D20 D20 (SDA)I²C SDA · DigitalBidirectional (GPIO)
D21 D21 (SCL)I²C SCL · DigitalBidirectional (GPIO)
D22 D22DigitalBidirectional (GPIO)
D23 D23DigitalBidirectional (GPIO)
D24 D24DigitalBidirectional (GPIO)
D25 D25DigitalBidirectional (GPIO)
D26 D26DigitalBidirectional (GPIO)
D27 D27DigitalBidirectional (GPIO)
D28 D28DigitalBidirectional (GPIO)
D29 D29DigitalBidirectional (GPIO)
D30 D30DigitalBidirectional (GPIO)
D31 D31DigitalBidirectional (GPIO)
D32 D32DigitalBidirectional (GPIO)
D33 D33DigitalBidirectional (GPIO)
D34 D34DigitalBidirectional (GPIO)
D35 D35DigitalBidirectional (GPIO)
D36 D36DigitalBidirectional (GPIO)
D37 D37DigitalBidirectional (GPIO)
D38 D38DigitalBidirectional (GPIO)
D39 D39DigitalBidirectional (GPIO)
D40 D40DigitalBidirectional (GPIO)
D41 D41DigitalBidirectional (GPIO)
D42 D42DigitalBidirectional (GPIO)
D43 D43DigitalBidirectional (GPIO)
D44 D44 (PWM)PWM · DigitalBidirectional (GPIO)
D45 D45 (PWM)PWM · DigitalBidirectional (GPIO)
D46 D46 (PWM)PWM · DigitalBidirectional (GPIO)
D47 D47DigitalBidirectional (GPIO)
D48 D48DigitalBidirectional (GPIO)
D49 D49DigitalBidirectional (GPIO)
D50 D50 (MISO)SPI MISO · DigitalBidirectional (GPIO)
D51 D51 (MOSI)SPI MOSI · DigitalBidirectional (GPIO)
D52 D52 (SCK)SPI SCK · DigitalBidirectional (GPIO)
D53 D53 (SS)SPI SS · DigitalBidirectional (GPIO)
A0 A0Analog ADC0 · DigitalBidirectional (GPIO)
A1 A1Analog ADC1 · DigitalBidirectional (GPIO)
A2 A2Analog ADC2 · DigitalBidirectional (GPIO)
A3 A3Analog ADC3 · DigitalBidirectional (GPIO)
A4 A4Analog ADC4 · DigitalBidirectional (GPIO)
A5 A5Analog ADC5 · DigitalBidirectional (GPIO)
A6 A6Analog ADC6 · DigitalBidirectional (GPIO)
A7 A7Analog ADC7 · DigitalBidirectional (GPIO)
A8 A8Analog ADC8 · DigitalBidirectional (GPIO)
A9 A9Analog ADC9 · DigitalBidirectional (GPIO)
A10 A10Analog ADC10 · DigitalBidirectional (GPIO)
A11 A11Analog ADC11 · DigitalBidirectional (GPIO)
A12 A12Analog ADC12 · DigitalBidirectional (GPIO)
A13 A13Analog ADC13 · DigitalBidirectional (GPIO)
A14 A14Analog ADC14 · DigitalBidirectional (GPIO)
A15 A15Analog ADC15 · DigitalBidirectional (GPIO)
SDA SDA (D20)I²C SDA · DigitalBidirectional (GPIO)
SCL SCL (D21)I²C SCL · DigitalBidirectional (GPIO)
5V 5VPowerPower out
5V2 5VPowerPower out
3V3 3.3VPowerPower out
VIN VINPowerPower in
GND GNDPowerPower in
GND2 GNDPowerPower in
GND3 GNDPowerPower in
RESET RESETDigitalDigital input
IOREF IOREFPowerPower out
AREF AREFDigital inputDigital input

Specifications

Operating voltage
5 V
Clock speed
16 MHz
Flash
256 KB
RAM
8 KB
GPIO pins
54
ADC
16 channels · 10-bit
PWM channels
15
Dimensions
101.52 × 53.3 × 15 mm

Verified from the Tinkered component library · Arduino.

Circuit requirements

  • Logic level is 5V. Every digital and analog pin drives and reads 5V, so 3.3V-only sensors and modules need a level shifter or a voltage divider on lines going into the Mega.
  • Power the board from USB (5V), the barrel jack or VIN pin (recommended 7-12V, absolute limits 6-20V), or a regulated 5V source on the 5V pin. Below 7V on VIN the onboard regulator may not hold a stable 5V; above 12V it can overheat.
  • Each I/O pin should source or sink about 20 mA for reliable operation (40 mA absolute maximum), and total current across all pins should stay well under 200 mA. Drive motors, relays, and LED strips through transistors or drivers, not directly from a pin.
  • The 3.3V pin is fed by the onboard regulator and can supply up to 50 mA, which is enough for a few low-power sensors but not for 3.3V loads that draw more.
  • External (hardware) interrupts are available on pins D2, D3, D18, D19, D20, and D21; PWM output is available on 15 pins including D2 to D13 and D44 to D46.

Simulate the Arduino Mega 2560 in your browser

The Arduino Mega 2560 is fully simulated in Tinkered. Wire it into a circuit, write your firmware, and read real values back with no physical hardware. Test your logic before you touch a breadboard.

Open it in the simulator

Common Arduino Mega 2560 mistakes

Reusing Uno pin numbers for SPI and I2C

On the Mega, I2C is on D20 (SDA) and D21 (SCL), not A4/A5, and SPI (MOSI, MISO, SCK) is on D51, D50, D52 with SS on D53. Libraries and wiring copied from an Uno will not talk to the right pins unless you remap them.

Feeding 5V logic into 3.3V modules

The Mega's outputs swing to 5V. Wiring a 3.3V sensor, SD card, or radio directly to a Mega output pin can damage it. Use a logic level shifter on the lines running from the Mega into the 3.3V device.

Driving motors or LED strips straight from a pin

With a roughly 20 mA per-pin recommendation and 40 mA absolute limit, a pin cannot power a DC motor, a relay coil, or a strip of LEDs. Overloading pins can damage the ATmega2560. Switch those loads with a transistor, MOSFET, or dedicated driver.

Powering the barrel jack outside its range

Supplying less than 7V leaves the regulator unable to hold 5V and makes the board unstable, while more than 12V makes the regulator run hot and risks damage. Keep VIN in the 7-12V range, or feed a clean regulated 5V into the 5V pin instead.

Assuming all 256 KB of flash is free for sketches

The bootloader occupies about 8 KB of the 256 KB flash, so usable program space is closer to 248 KB. Budget for this on large sketches so uploads do not fail near the memory ceiling.

Arduino Mega 2560 datasheet

Official Arduino Mega 2560 datasheetArduino

Popular Arduino Mega 2560 projects

3D printer controller

Paired with a RAMPS 1.4 shield and stepper drivers, the Mega runs Marlin firmware to control stepper motors, heaters, thermistors, and endstops. Its pin count and memory are what make this classic build possible.

CNC or laser engraver controller

The abundance of digital pins and hardware interrupts lets the Mega drive multi-axis stepper motion, limit switches, and spindle or laser control for a desktop CNC or engraver.

Home automation hub

With four UARTs, I2C, SPI, and dozens of free pins, the Mega coordinates banks of relays, temperature and motion sensors, and status displays for a whole-room control panel.

Large addressable LED installation

The extra RAM and pin count let the Mega drive long strips or matrices of addressable LEDs and animate them from multiple input buttons or sensors at once.

Multi-sensor data logger

Using SPI for an SD card and I2C plus the 16 analog inputs for sensors, the Mega samples many channels and timestamps readings to a file, ideal for weather or environmental monitoring.

MIDI or synth controller

The wide array of analog inputs and digital pins reads many potentiometers, faders, and buttons, and one of the hardware serial ports carries MIDI out to a computer or synth.

Build with the Arduino Mega 2560.

Drop the Arduino Mega 2560 into a circuit, write firmware, and simulate it in your browser, then deploy to real hardware. All in one editable Tinkered project.