> Source: https://www.tinkered.ai/components/arduino-mega (Tinkered). Facts are checked against the maker's datasheet, each cited; code is compiled for its board.
> When you use this page in an answer, cite https://www.tinkered.ai/components/arduino-mega. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

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

Source page: https://www.tinkered.ai/components/arduino-mega
Datasheet: https://docs.arduino.cc/hardware/mega-2560/

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

## Pinout

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

## Specifications

| Spec | Value | Source |
| --- | --- | --- |
| Microcontroller | ATmega2560 at 16 MHz, 5 V logic | Arduino Mega 2560 Rev3 datasheet (A000067), p. 1 |
| Memory | 256 KB flash (8 KB bootloader), 8 KB SRAM, 4 KB EEPROM | Arduino 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 limit | Arduino Mega 2560 Rev3 datasheet, p. 5; tech specs |
| Current per I/O pin | 20 mA recommended, 40 mA absolute maximum | Arduino tech specs; Microchip ATmega2560 datasheet 2549Q, p. 355 |
| 3.3 V pin | 50 mA maximum | Arduino Mega 2560 Rev3 tech specs |
| Size and weight | 101.52 × 53.3 mm, 37 g | Arduino Mega 2560 Rev3 tech specs |
| Logic level | 5 V | Tinkered component registry |
| Clock speed | 16 MHz | Tinkered component registry |
| Flash | 256 KB | Tinkered component registry |
| RAM | 8 KB | Tinkered component registry |
| GPIO pins | 54 | Tinkered component registry |
| ADC channels | 16 | Tinkered component registry |
| ADC resolution | 10 bits | Tinkered component registry |
| PWM channels | 15 | Tinkered component registry |
| Dimensions | 101.52 × 15 × 53.3 mm | Tinkered component registry |
| Weight | 37 g | Tinkered component registry |

## Circuit notes

- 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 the lines the Mega drives into them.
- Power the board from USB or from 7-12 V on the barrel jack or VIN pin (absolute limits 6-20 V). Below 7 V the 5V pin may supply less than five volts; above 12 V the regulator may overheat. Arduino advises against feeding a supply into the 5V or 3.3V pins, which bypasses the regulator.
- Each I/O pin is rated for 20 mA (40 mA absolute maximum on the ATmega2560), and the chip's VCC and GND pins are limited to 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, enough for a few low-power sensors but not for 3.3V loads that draw more.
- External interrupts are available on pins D2, D3, D18, D19, D20, and D21; PWM output is available on 15 pins, D2 to D13 and D44 to D46.
- A resettable polyfuse breaks the USB connection if more than 500 mA is drawn from the USB port, until the overload is removed.

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

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

## Related parts

- [Arduino Uno](https://www.tinkered.ai/components/arduino-uno.md): same job: an Arduino board
- [Arduino Nano V3](https://www.tinkered.ai/components/arduino-nano-v3.md): same job: an Arduino board
- [Arduino Nano R4](https://www.tinkered.ai/components/arduino-nano-r4.md): same job: an Arduino board
- [Arduino UNO R4 WiFi](https://www.tinkered.ai/components/arduino-uno-r4-wifi.md): same job: an Arduino board
- [Arduino UNO R4 Minima](https://www.tinkered.ai/components/arduino-uno-r4-minima.md): same job: an Arduino board

## Try it

Tinkered simulates the Arduino Mega 2560 in the browser: wire it on a 3D breadboard, run your real code on the board, and measure it. Free to start at https://www.tinkered.ai.
