Component guide · Beginner · 4 min read
Arduino Mega 2560

Pinout, Specs and When You Need More Pins
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
The Arduino Mega 2560 is a bigger Uno: the same 5 V, 16 MHz programming model, but with 54 digital pins (15 with PWM), 16 analog inputs, four hardware serial ports and eight times the flash memory. Choose it when a project needs lots of inputs and outputs or several serial devices, such as a 3D printer controller, a big LED or relay panel, or a robot with GPS, Bluetooth and a display at once.
Key specs at a glance
- Microcontroller
- ATmega2560, 16 MHz, 5 V logic
- Flash / SRAM / EEPROM
- 256 KB (8 KB bootloader) / 8 KB / 4 KB
- Digital I/O
- 54, of which 15 PWM (2 to 13, 44 to 46)
- Analog inputs
- 16 (A0 to A15), 10-bit
- Serial ports
- 4: Serial (0/1), Serial1 (19/18), Serial2 (17/16), Serial3 (15/14)
- Input voltage
- 7 to 12 V recommended on the barrel jack
- Pin current
- 20 mA recommended, 40 mA absolute maximum
Arduino Mega pinout: the pins that matter
| Function | Mega 2560 pins | Uno equivalent |
|---|---|---|
| I2C | 20 (SDA), 21 (SCL), also the SDA/SCL header | A4, A5 |
| SPI | 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS), plus ICSP header | 12, 11, 13, 10 |
| Serial | 0/1 (USB), 19/18, 17/16, 15/14 (RX/TX) | 0/1 only |
| External interrupts | 2, 3, 18, 19, 20, 21 | 2, 3 |
| PWM | 2 to 13, 44, 45, 46 | 3, 5, 6, 9, 10, 11 |
| Analog in | A0 to A15 | A0 to A5 |
| Built-in LED | 13 | 13 |
- I2C
- Mega 2560 pins:
- 20 (SDA), 21 (SCL), also the SDA/SCL header
- Uno equivalent:
- A4, A5
- SPI
- Mega 2560 pins:
- 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS), plus ICSP header
- Uno equivalent:
- 12, 11, 13, 10
- Serial
- Mega 2560 pins:
- 0/1 (USB), 19/18, 17/16, 15/14 (RX/TX)
- Uno equivalent:
- 0/1 only
- External interrupts
- Mega 2560 pins:
- 2, 3, 18, 19, 20, 21
- Uno equivalent:
- 2, 3
- PWM
- Mega 2560 pins:
- 2 to 13, 44, 45, 46
- Uno equivalent:
- 3, 5, 6, 9, 10, 11
- Analog in
- Mega 2560 pins:
- A0 to A15
- Uno equivalent:
- A0 to A5
- Built-in LED
- Mega 2560 pins:
- 13
- Uno equivalent:
- 13
When to choose a Mega instead of an Uno
keypads, several displays, relay banks, LED panels, or a big model railway.
GPS, Bluetooth, a GSM module and a sensor at the same time without SoftwareSerial.
256 KB of flash fits sketches and libraries that overflow an Uno.
the classic RAMPS 1.4 board plugs onto a Mega.
If you need speed, Wi-Fi or lots of RAM rather than pins, an ESP32 is usually a better and cheaper choice; port expanders such as the PCF8574 or MCP23017 can also add pins to a smaller board. See how to choose a microcontroller.
Using Uno shields on a Mega
Most Uno shields fit the Mega's header, but check two things. SPI: on the Mega, SPI is on pins 50 to 53 and the ICSP header, not on 11 to 13, so older shields that use pins 11 to 13 for SPI (some Ethernet and SD shields) need jumpers or a library change. I2C: shields that use A4 and A5 for I2C will not work unless they also connect to the SDA/SCL header near AREF, which all R3 shields do. Pin 10 stays as the usual chip-select for SD and Ethernet shields, but pin 53 must be left as an output for SPI to work.
Power and current limits
The barrel jack takes 7 to 12 V. At 12 V the on-board 5 V regulator gets hot if you draw more than a few hundred milliamps from the 5V pin, so power servos, motors and LED strips from their own supply and share only ground. Each I/O pin should source or sink 20 mA or less; the total for the chip is 200 mA. Many clone Megas use a CH340 USB chip instead of the ATmega16U2: they work the same but may need the CH340 driver on older Windows. See USB to TTL adapters and powering an Arduino.
Using the extra serial ports
Each port has its own object, so there is no need for SoftwareSerial.
void setup() {
Serial.begin(115200); // USB to computer
Serial1.begin(9600); // GPS: module TX -> pin 19 (RX1)
}
void loop() {
while (Serial1.available()) {
Serial.write(Serial1.read()); // pass NMEA sentences through
}
}Try it: ADC resolution calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Using pins 11 to 13 for SPI as on an Uno.
- Feeding 12 V and drawing servo current from the 5V pin until the regulator overheats.
- Using Serial (pins 0/1) for a module and then wondering why uploads fail.
- Forgetting that analog pins A0 to A15 are 5 V maximum.
- Choosing a Mega for speed; it runs at the same 16 MHz as an Uno.
Frequently asked questions
How many pins does an Arduino Mega have?
54 digital I/O pins, 15 of which support PWM, and 16 analog inputs. It also has four hardware serial ports.
What are the I2C pins on the Arduino Mega?
Pin 20 is SDA and pin 21 is SCL. They are also on the SDA and SCL header next to AREF.
Is Arduino Mega code the same as Uno code?
Yes, the language and most libraries are the same. Select 'Arduino Mega or Mega 2560' as the board, and change pin numbers for SPI, I2C and serial if needed.
Can an Arduino Mega use Uno shields?
Most fit and work. Older shields that use pins 11 to 13 for SPI or A4/A5 for I2C may need jumper wires or a code change.
Is the Arduino Mega faster than the Uno?
No. Both run at 16 MHz. The Mega has more pins and memory, not more speed. For speed, use an ESP32 or a Raspberry Pi Pico.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 19 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



