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.

  • MicrocontrollerATmega2560 at 16 MHz, 5 V logic
  • Memory256 KB flash (8 KB bootloader), 8 KB SRAM, 4 KB EEPROM
  • I/O54 digital (15 PWM: D2 to D13, D44 to D46), 16 analog inputs (10-bit)
  • Serial ports4 UARTs: D0/D1, D19/D18, D17/D16, D15/D14 (RX/TX)
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.
In short

The Arduino Mega 2560 Rev3 is a 5 V board built on the ATmega2560 at 16 MHz, with 54 digital pins (15 with PWM), 16 analog inputs and four hardware serial ports (Arduino Mega 2560 Rev3 datasheet, p. 1). Power it over USB or with 7 V to 12 V on VIN or the barrel jack (datasheet, p. 5), and keep each I/O pin at 20 mA (Arduino tech specs). Unlike the Uno, I2C is on D20 (SDA) and D21 (SCL) (datasheet, p. 10) and SPI is on D50 to D53.

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 many Uno shields still fit (check their I2C and SPI pins first), 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 pinout

tinkered.ai/components/arduino-megaArduino Mega 2560D0UART RX · DigitalD1UART TX · DigitalD2PWM · DigitalD3PWM · DigitalD4PWM · DigitalD5PWM · DigitalD6PWM · DigitalD7PWM · DigitalD8PWM · DigitalD9PWM · DigitalD10PWM · DigitalD11PWM · DigitalD12PWM · DigitalD13PWM · DigitalD14UART TX3 · DigitalD15UART RX3 · DigitalD16UART TX2 · DigitalD17UART RX2 · DigitalD18UART TX1 · DigitalD19UART RX1 · DigitalD20I2C SDA · DigitalD21I2C SCL · DigitalD22DigitalD23DigitalD24DigitalD25DigitalD26DigitalD27DigitalD28DigitalD29DigitalD30DigitalD31DigitalD32DigitalD33DigitalD34DigitalD35DigitalD36DigitalD37DigitalD38DigitalD39DigitalD40DigitalD41DigitalD42DigitalD43DigitalD44PWM · DigitalD45PWM · DigitalD46PWM · DigitalD47DigitalD48DigitalD49DigitalD50SPI MISO · DigitalD51SPI MOSI · DigitalD52SPI SCK · DigitalD53SPI SS · DigitalA0ADC0 · DigitalA1ADC1 · DigitalA2ADC2 · DigitalA3ADC3 · DigitalA4ADC4 · DigitalA5ADC5 · DigitalA6ADC6 · DigitalA7ADC7 · DigitalA8ADC8 · DigitalA9ADC9 · DigitalA10ADC10 · DigitalA11ADC11 · DigitalA12ADC12 · DigitalA13ADC13 · DigitalA14ADC14 · DigitalA15ADC15 · DigitalSDAI2C SDA · DigitalSCLI2C SCL · Digital5VPower5V2Power3V3PowerVINPowerGNDGroundGND2GroundGND3GroundRESETDigitalIOREFPowerAREFAREF
PinFunctionType
D0UART RX, Digital5 Vbidirectional
D1UART TX, Digital5 Vbidirectional
D2PWM, Digital5 Vbidirectional
D3PWM, Digital5 Vbidirectional
D4PWM, Digital5 Vbidirectional
D5PWM, Digital5 Vbidirectional
D6PWM, Digital5 Vbidirectional
D7PWM, Digital5 Vbidirectional
D8PWM, Digital5 Vbidirectional
D9PWM, Digital5 Vbidirectional
D10PWM, Digital5 Vbidirectional
D11PWM, Digital5 Vbidirectional
D12PWM, Digital5 Vbidirectional
D13PWM, Digital5 Vbidirectional
D14UART TX3, Digital5 Vbidirectional
D15UART RX3, Digital5 Vbidirectional
D16UART TX2, Digital5 Vbidirectional
D17UART RX2, Digital5 Vbidirectional
D18UART TX1, Digital5 Vbidirectional
D19UART RX1, Digital5 Vbidirectional
D20I2C SDA, Digital5 Vbidirectional
D21I2C SCL, Digital5 Vbidirectional
D22Digital5 Vbidirectional
D23Digital5 Vbidirectional
D24Digital5 Vbidirectional
D25Digital5 Vbidirectional
D26Digital5 Vbidirectional
D27Digital5 Vbidirectional
D28Digital5 Vbidirectional
D29Digital5 Vbidirectional
D30Digital5 Vbidirectional
D31Digital5 Vbidirectional
D32Digital5 Vbidirectional
D33Digital5 Vbidirectional
D34Digital5 Vbidirectional
D35Digital5 Vbidirectional
D36Digital5 Vbidirectional
D37Digital5 Vbidirectional
D38Digital5 Vbidirectional
D39Digital5 Vbidirectional
D40Digital5 Vbidirectional
D41Digital5 Vbidirectional
D42Digital5 Vbidirectional
D43Digital5 Vbidirectional
D44PWM, Digital5 Vbidirectional
D45PWM, Digital5 Vbidirectional
D46PWM, Digital5 Vbidirectional
D47Digital5 Vbidirectional
D48Digital5 Vbidirectional
D49Digital5 Vbidirectional
D50SPI MISO, Digital5 Vbidirectional
D51SPI MOSI, Digital5 Vbidirectional
D52SPI SCK, Digital5 Vbidirectional
D53SPI SS, Digital5 Vbidirectional
A0ADC0, Digital5 Vbidirectional
A1ADC1, Digital5 Vbidirectional
A2ADC2, Digital5 Vbidirectional
A3ADC3, Digital5 Vbidirectional
A4ADC4, Digital5 Vbidirectional
A5ADC5, Digital5 Vbidirectional
A6ADC6, Digital5 Vbidirectional
A7ADC7, Digital5 Vbidirectional
A8ADC8, Digital5 Vbidirectional
A9ADC9, Digital5 Vbidirectional
A10ADC10, Digital5 Vbidirectional
A11ADC11, Digital5 Vbidirectional
A12ADC12, Digital5 Vbidirectional
A13ADC13, Digital5 Vbidirectional
A14ADC14, Digital5 Vbidirectional
A15ADC15, Digital5 Vbidirectional
SDAI2C SDA, Digital5 Vbidirectional
SCLI2C SCL, Digital5 Vbidirectional
5V5V5 Vpower out
5V25Vpower out
3V33.3V3.3 Vpower out
VINVINpower in
GNDGNDpower in
GND2GNDpower in
GND3GNDpower in
RESETDigital5 Vinput
IOREFIOREFpower out
AREFAREFinput

Specifications

Microcontroller
ATmega2560 at 16 MHz, 5 V logicArduino Mega 2560 Rev3 datasheet (A000067), p. 1
Memory
256 KB flash (8 KB bootloader), 8 KB SRAM, 4 KB EEPROMArduino Mega 2560 Rev3 datasheet, p. 2
I/O
54 digital (15 PWM: D2 to D13, D44 to D46), 16 analog inputs (10-bit)Arduino Mega 2560 Rev3 datasheet, p. 2; Arduino store description
Serial ports
4 UARTs: D0/D1, D19/D18, D17/D16, D15/D14 (RX/TX)Arduino Mega 2560 Rev3 store description
I2C and SPI
SDA D20, SCL D21; SPI D50 (MISO), D51 (MOSI), D52 (SCK), D53 (SS)Arduino Mega 2560 Rev3 datasheet, p. 10; store description
Input voltage (VIN / jack)
7 to 12 V recommended, 6 to 20 V limitArduino Mega 2560 Rev3 datasheet, p. 5; tech specs
Current per I/O pin
20 mA recommended, 40 mA absolute maximumArduino tech specs; Microchip ATmega2560 datasheet 2549Q, p. 355
3.3 V pin
50 mA maximumArduino Mega 2560 Rev3 tech specs
Size and weight
101.52 × 53.3 mm, 37 gArduino Mega 2560 Rev3 tech specs
Logic level
5 V
Clock speed
16 MHz
Flash
256 KB
RAM
8 KB
GPIO pins
54
ADC channels
16
ADC resolution
10 bits
PWM channels
15
Dimensions
101.52 × 15 × 53.3 mm
Weight
37 g

From the Arduino's datasheet, published by Arduino.

Common mistakes

  1. 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 that use the SPI and Wire objects follow the board, but wiring copied from an Uno tutorial lands on the wrong pins.

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

  3. Driving motors or LED strips straight from a pin

    With a 20 mA per-pin rating and a 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.

  4. 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 power the board over USB.

  5. Assuming all 256 KB of flash is free for sketches

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

Arduino Mega 2560 questions

What are the I2C pins on the Arduino Mega 2560?

SDA is D20 and SCL is D21 (Arduino Mega 2560 Rev3 datasheet, p. 10), also repeated on the two pins beside AREF. They are not A4 and A5 as on the Uno, so a sensor wired to A4/A5 out of Uno habit will not answer.

Arduino Mega vs Uno: which should I use?

Both run at 5 V and 16 MHz, but the Mega has 54 digital pins, 16 analog inputs, four UARTs and 256 KB of flash, against the Uno's 14 digital pins, 6 analog inputs, one UART and 32 KB (Arduino tech specs). Choose the Mega when you run out of pins, serial ports or program memory; otherwise the smaller Uno is enough.

Can I power the Arduino Mega with a 12 V adapter?

Yes: 12 V is the top of the recommended 7 V to 12 V range on the jack or VIN (datasheet, p. 5). Above 12 V the regulator may overheat, and it also has to burn off more heat the more current the 5 V rail supplies, so keep heavy 5 V loads on their own supply.

Can I use 3.3 V sensors with the Arduino Mega?

Yes, with care: power them from the 3.3V pin only if they draw 50 mA or less (tech specs), and put a level shifter or divider on every line the Mega drives, since its outputs swing to 5 V.

Which pins on the Arduino Mega support interrupts?

Six pins take attachInterrupt(): D2, D3, D18, D19, D20 and D21 (Arduino Mega 2560 store description). Note that D20 and D21 are also the I2C bus and D18/D19 are Serial1, so plan which function each pin serves.

Why doesn't my Uno shield work on the Mega?

Shields that use I2C on A4/A5 or SPI on D11 to D13 expect the Uno's pinout. On the Mega, I2C is D20/D21 and SPI is D50 to D53 (also on the ICSP header), so the shield needs rewiring or must take SPI from the ICSP header.

Build something with the Arduino Mega 2560

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

    Build this
  • 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.

    Build this
  • 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.

    Build this
  • 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.

    Build this
  • 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.

    Build this
  • 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 this
For AI assistants

This page as plain Markdown, for ChatGPT, Claude or your own agent. /components/arduino-mega.md

What will you build with it?