Function: what an Arduino Mega 2560 does in a circuit
The big Arduino: 54 digital pins, 16 analog inputs and four serial ports, for projects that run out of pins on an Uno.
- Runs larger sketches, with eight times the Uno's program memory
- Reads and switches up to 54 digital pins and 16 analog inputs
- Talks to several serial devices at once through four serial ports
Arduino Mega 2560 key facts
| Microcontroller | ATmega2560 (8-bit AVR, 16 MHz) |
|---|---|
| Operating voltage | 5 V |
| Digital pins | 54 (PWM on 2 to 13 and 44 to 46) |
| Analog inputs | 16 (A0 to A15), 10-bit: 0 to 1023 |
| I²C | pin 20 (SDA), pin 21 (SCL) |
| SPI | pin 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS) |
| Serial ports | 4: Serial on pins 0 (RX) and 1 (TX), Serial1 on 19 and 18, Serial2 on 17 and 16, Serial3 on 15 and 14 |
| Interrupt pins | 2, 3, 18, 19, 20, 21 |
| Memory | 256 KB flash (8 KB bootloader), 8 KB RAM, 4 KB EEPROM |
| Size | 101.5 × 53.3 mm |
| Built-in LED | pin 13 |
How it works
The Mega is built around the ATmega2560, an 8-bit AVR chip at 16 MHz and 5 V like the Uno, but with 100 legs. It has digital pins 0 to 53, with PWM on 2 to 13 and 44 to 46, and analog inputs A0 to A15. I²C moves to pins 20 (SDA) and 21 (SCL), and there are three extra serial ports on pins 14 to 19, used in code as Serial1, Serial2 and Serial3. Text sent on a TX pin arrives at whichever RX pin it is wired to; only Serial (pins 0 and 1, the USB cable) shows in the Serial Monitor. The SPI pins are 50 to 53. Six pins can trigger interrupts: 2, 3, 18, 19, 20 and 21. Memory is much larger: 256 KB of flash, 8 KB of RAM and 4 KB of EEPROM. The left part of the board has the same pin layout as the Uno, so Uno shields fit.
What it is made of
- Chip: Silicon die in a 100-pin flat black package (TQFP) SiCHO
- Board: Glass-fibre and epoxy with copper tracks under solder mask CuSiO
- Headers and sockets: Brass contacts plated with tin, in black plastic CuZnSn
- Crystal: A thin slice of quartz in a metal can SiO
Where the materials come from: Silicon from quartz sand; copper from chalcopyrite; tin from cassiterite; zinc from sphalerite.
The chemistry
The copper tracks are made by etching: a chemical bath dissolves the copper that is not protected, leaving only the wiring pattern on the board.
Biology connection
More pins are like more nerve endings: an octopus arm has far more sensors and muscles to control than a finger, so it needs many more connections to its nervous system. Reflex arc →
Safety and the environment
On the Mega, I²C is on pins 20 and 21, not A4 and A5, and SPI is on 50 to 53. Keep the total current from all pins under about 200 mA.
Did you know? The Mega 2560 has eight times the program memory of the Uno, which is why many 3D printers use it as their controller.
Microcontroller simulatorArduino Uno R3Arduino Nano Elements inside: SiCHOCuZnSn
Try it in the simulator
In Free build, choose Arduino Mega 2560 under Board. Use pins 22 to 53 for extra LEDs, buttons or servos, read up to 16 potentiometers on A0 to A15, and remember that I²C parts go on pins 20 (SDA) and 21 (SCL).
Questions students ask
What does an Arduino Mega 2560 do?
The big Arduino: 54 digital pins, 16 analog inputs and four serial ports, for projects that run out of pins on an Uno. Main functions: runs larger sketches, with eight times the Uno's program memory; reads and switches up to 54 digital pins and 16 analog inputs; talks to several serial devices at once through four serial ports.
When should I use an Arduino Mega instead of an Uno?
Use a Mega when a project needs more than the Uno's 20 pins, more than 2 KB of RAM, or more than one serial port: for example many servos, a large LED matrix, or a robot with many sensors. The code is written the same way, but I²C is on pins 20 and 21.
How does an Arduino Mega 2560 work?
The Mega is built around the ATmega2560, an 8-bit AVR chip at 16 MHz and 5 V like the Uno, but with 100 legs. It has digital pins 0 to 53, with PWM on 2 to 13 and 44 to 46, and analog inputs A0 to A15. I²C moves to pins 20 (SDA) and 21 (SCL), and there are three extra serial ports on pins 14 to 19, used in code as Serial1, Serial2 and Serial3. Text sent on a TX pin arrives at whichever RX pin it is wired to; only Serial (pins 0 and 1, the USB cable) shows in the Serial Monitor. The SPI pins are 50 to 53. Six pins can trigger interrupts: 2, 3, 18, 19, 20 and 21. Memory is much larger: 256 KB of flash, 8 KB of RAM and 4 KB of EEPROM. The left part of the board has the same pin layout as the Uno, so Uno shields fit.
What is an Arduino Mega 2560 made of?
Chip: Silicon die in a 100-pin flat black package (TQFP). Board: Glass-fibre and epoxy with copper tracks under solder mask. Headers and sockets: Brass contacts plated with tin, in black plastic. Crystal: A thin slice of quartz in a metal can.
Is an Arduino Mega 2560 safe? How should it be recycled?
On the Mega, I²C is on pins 20 and 21, not A4 and A5, and SPI is on 50 to 53. Keep the total current from all pins under about 200 mA.
More boards and wiring
Connected tools
The same idea from another angle, across the site.