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)

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
| Pin | Function | Type |
|---|---|---|
| D0 | UART RX, Digital5 V | bidirectional |
| D1 | UART TX, Digital5 V | bidirectional |
| D2 | PWM, Digital5 V | bidirectional |
| D3 | PWM, Digital5 V | bidirectional |
| D4 | PWM, Digital5 V | bidirectional |
| D5 | PWM, Digital5 V | bidirectional |
| D6 | PWM, Digital5 V | bidirectional |
| D7 | PWM, Digital5 V | bidirectional |
| D8 | PWM, Digital5 V | bidirectional |
| D9 | PWM, Digital5 V | bidirectional |
| D10 | PWM, Digital5 V | bidirectional |
| D11 | PWM, Digital5 V | bidirectional |
| D12 | PWM, Digital5 V | bidirectional |
| D13 | PWM, Digital5 V | bidirectional |
| D14 | UART TX3, Digital5 V | bidirectional |
| D15 | UART RX3, Digital5 V | bidirectional |
| D16 | UART TX2, Digital5 V | bidirectional |
| D17 | UART RX2, Digital5 V | bidirectional |
| D18 | UART TX1, Digital5 V | bidirectional |
| D19 | UART RX1, Digital5 V | bidirectional |
| D20 | I2C SDA, Digital5 V | bidirectional |
| D21 | I2C SCL, Digital5 V | bidirectional |
| D22 | Digital5 V | bidirectional |
| D23 | Digital5 V | bidirectional |
| D24 | Digital5 V | bidirectional |
| D25 | Digital5 V | bidirectional |
| D26 | Digital5 V | bidirectional |
| D27 | Digital5 V | bidirectional |
| D28 | Digital5 V | bidirectional |
| D29 | Digital5 V | bidirectional |
| D30 | Digital5 V | bidirectional |
| D31 | Digital5 V | bidirectional |
| D32 | Digital5 V | bidirectional |
| D33 | Digital5 V | bidirectional |
| D34 | Digital5 V | bidirectional |
| D35 | Digital5 V | bidirectional |
| D36 | Digital5 V | bidirectional |
| D37 | Digital5 V | bidirectional |
| D38 | Digital5 V | bidirectional |
| D39 | Digital5 V | bidirectional |
| D40 | Digital5 V | bidirectional |
| D41 | Digital5 V | bidirectional |
| D42 | Digital5 V | bidirectional |
| D43 | Digital5 V | bidirectional |
| D44 | PWM, Digital5 V | bidirectional |
| D45 | PWM, Digital5 V | bidirectional |
| D46 | PWM, Digital5 V | bidirectional |
| D47 | Digital5 V | bidirectional |
| D48 | Digital5 V | bidirectional |
| D49 | Digital5 V | bidirectional |
| D50 | SPI MISO, Digital5 V | bidirectional |
| D51 | SPI MOSI, Digital5 V | bidirectional |
| D52 | SPI SCK, Digital5 V | bidirectional |
| D53 | SPI SS, Digital5 V | bidirectional |
| A0 | ADC0, Digital5 V | bidirectional |
| A1 | ADC1, Digital5 V | bidirectional |
| A2 | ADC2, Digital5 V | bidirectional |
| A3 | ADC3, Digital5 V | bidirectional |
| A4 | ADC4, Digital5 V | bidirectional |
| A5 | ADC5, Digital5 V | bidirectional |
| A6 | ADC6, Digital5 V | bidirectional |
| A7 | ADC7, Digital5 V | bidirectional |
| A8 | ADC8, Digital5 V | bidirectional |
| A9 | ADC9, Digital5 V | bidirectional |
| A10 | ADC10, Digital5 V | bidirectional |
| A11 | ADC11, Digital5 V | bidirectional |
| A12 | ADC12, Digital5 V | bidirectional |
| A13 | ADC13, Digital5 V | bidirectional |
| A14 | ADC14, Digital5 V | bidirectional |
| A15 | ADC15, Digital5 V | bidirectional |
| SDA | I2C SDA, Digital5 V | bidirectional |
| SCL | I2C SCL, Digital5 V | bidirectional |
| 5V | 5V5 V | power out |
| 5V2 | 5V | power out |
| 3V3 | 3.3V3.3 V | power out |
| VIN | VIN | power in |
| GND | GND | power in |
| GND2 | GND | power in |
| GND3 | GND | power in |
| RESET | Digital5 V | input |
| IOREF | IOREF | power out |
| AREF | AREF | input |
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
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.
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 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.
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.
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
- Build this
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.
This page as plain Markdown, for ChatGPT, Claude or your own agent. /components/arduino-mega.md