Arduino Mega 2560 R3 pinout
A big Arduino with 54 digital pins, 16 analog inputs and 4 serial ports. It uses 5 V logic, so 3.3 V-only sensors need a level shifter.
The real app with a simulated Arduino Mega 2560 R3, running in your browser. No install, nothing to plug in.
At a glance
- Chip
- ATmega2560
- Processor
- 8-bit AVR ATmega2560 at 16 MHz, 8 KB SRAM, 256 KB flash, 4 KB EEPROM
- Logic level
- 5 V. 3.3 V-only sensors need a level shifter.
- Flashing tool
- avrdude
- Arduino board (FQBN)
- arduino:avr:mega
- Live pin view in BoardPilot
- Yes (diagnostic agent available)
Pins to avoid or use with care
USB serial: TX0→1 (PE1), RX0←0 (PE0)
Used for uploading and the serial monitor. Anything connected here can break uploads.
Good pins for LEDs, buttons and signals
22, 23, 24, 25, 26, 27, 28, 29, ~2, ~3, ~4, ~5, ~6, ~7, ~8, ~9
Default pins in Arduino
- I2C
- SDA = SDA 20, SCL = SCL 21. Only these pins work with the Wire library defaults. I2C only works on 20 (SDA) and 21 (SCL); the SDA/SCL pins near AREF are the same signals. Both have 10 kΩ pull-ups to 5 V on the board.
- SPI
- MOSI = 51, MISO = 50, SCK = 52, CS = 53.
- Analog inputs
- A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15 (0–5 V)
All 85 pins
| Pin | GPIO | Chip pin | Functions | Notes |
|---|---|---|---|---|
| SCL | 21 | PD0 | GPIO, I2C_SCL (default), INT0 | Same signal as D21 (I2C clock). Has a 10 kΩ pull-up to 5 V on the board: 3.3 V-only I2C parts need a level shifter. |
| SDA | 20 | PD1 | GPIO, I2C_SDA (default), INT1 | Same signal as D20 (I2C data). Has a 10 kΩ pull-up to 5 V on the board: 3.3 V-only I2C parts need a level shifter. |
| AREF | — | ADC_REF | Analog reference input. Leave it unconnected unless your code calls analogReference(EXTERNAL); never power parts from it. | |
| GND | — | |||
| ~13 | 13 | PB7 | GPIO, PWM | The built-in LED "L" is on this pin. |
| ~12 | 12 | PB6 | GPIO, PWM | |
| ~11 | 11 | PB5 | GPIO, PWM | |
| ~10 | 10 | PB4 | GPIO, PWM | |
| ~9 | 9 | PH6 | GPIO, PWM | |
| ~8 | 8 | PH5 | GPIO, PWM | |
| ~7 | 7 | PH4 | GPIO, PWM | |
| ~6 | 6 | PH3 | GPIO, PWM | |
| ~5 | 5 | PE3 | GPIO, PWM | |
| ~4 | 4 | PG5 | GPIO, PWM | |
| ~3 | 3 | PE5 | GPIO, INT5, PWM | |
| ~2 | 2 | PE4 | GPIO, INT4, PWM | |
| TX0→1 | 1 | PE1 | GPIO, UART0_TX | Serial TX. Shared with the USB link: using it for parts can break uploads and the serial monitor. |
| RX0←0 | 0 | PE0 | GPIO, UART0_RX | Serial RX. Shared with the USB link: using it for parts can break uploads and the serial monitor. |
| TX3 14 | 14 | PJ1 | GPIO, UART3_TX | |
| RX3 15 | 15 | PJ0 | GPIO, UART3_RX | |
| TX2 16 | 16 | PH1 | GPIO, UART2_TX | |
| RX2 17 | 17 | PH0 | GPIO, UART2_RX | |
| TX1 18 | 18 | PD3 | GPIO, UART1_TX, INT3 | |
| RX1 19 | 19 | PD2 | GPIO, UART1_RX, INT2 | |
| SDA 20 | 20 | PD1 | GPIO, I2C_SDA (default), INT1 | Default I2C SDA. Has a 10 kΩ pull-up to 5 V on the board: 3.3 V-only I2C parts need a level shifter. |
| SCL 21 | 21 | PD0 | GPIO, I2C_SCL (default), INT0 | Default I2C SCL. Has a 10 kΩ pull-up to 5 V on the board: 3.3 V-only I2C parts need a level shifter. |
| IOREF | — | Tells shields that this board uses 5 V logic. Connected to 5V; not meant to power parts. | ||
| RESET | — | RESET | Reset input. Pull it LOW (or press the button) to restart the board. | |
| 3.3V | — | 3.3 V output, 50 mA max. Enough for one or two small sensors. | ||
| 5V | — | 5 V output from USB or the on-board regulator. | ||
| GND | — | |||
| GND | — | |||
| Vin | — | Power input (7-12 V recommended) from the barrel jack or an external supply. It is not fed from USB, so do not use it to power parts. | ||
| A0 | 54 | PF0 | GPIO, ADC0 | |
| A1 | 55 | PF1 | GPIO, ADC1 | |
| A2 | 56 | PF2 | GPIO, ADC2 | |
| A3 | 57 | PF3 | GPIO, ADC3 | |
| A4 | 58 | PF4 | GPIO, ADC4 | |
| A5 | 59 | PF5 | GPIO, ADC5 | |
| A6 | 60 | PF6 | GPIO, ADC6 | |
| A7 | 61 | PF7 | GPIO, ADC7 | |
| A8 | 62 | PK0 | GPIO, ADC8 | |
| A9 | 63 | PK1 | GPIO, ADC9 | |
| A10 | 64 | PK2 | GPIO, ADC10 | |
| A11 | 65 | PK3 | GPIO, ADC11 | |
| A12 | 66 | PK4 | GPIO, ADC12 | |
| A13 | 67 | PK5 | GPIO, ADC13 | |
| A14 | 68 | PK6 | GPIO, ADC14 | |
| A15 | 69 | PK7 | GPIO, ADC15 | |
| 5V | — | 5 V, same rail as the 5V pin. | ||
| 5V | — | 5 V, same rail as the 5V pin. | ||
| 22 | 22 | PA0 | GPIO | |
| 23 | 23 | PA1 | GPIO | |
| 24 | 24 | PA2 | GPIO | |
| 25 | 25 | PA3 | GPIO | |
| 26 | 26 | PA4 | GPIO | |
| 27 | 27 | PA5 | GPIO | |
| 28 | 28 | PA6 | GPIO | |
| 29 | 29 | PA7 | GPIO | |
| 30 | 30 | PC7 | GPIO | |
| 31 | 31 | PC6 | GPIO | |
| 32 | 32 | PC5 | GPIO | |
| 33 | 33 | PC4 | GPIO | |
| 34 | 34 | PC3 | GPIO | |
| 35 | 35 | PC2 | GPIO | |
| 36 | 36 | PC1 | GPIO | |
| 37 | 37 | PC0 | GPIO | |
| 38 | 38 | PD7 | GPIO | |
| 39 | 39 | PG2 | GPIO | |
| 40 | 40 | PG1 | GPIO | |
| 41 | 41 | PG0 | GPIO | |
| 42 | 42 | PL7 | GPIO | |
| 43 | 43 | PL6 | GPIO | |
| 44 | 44 | PL5 | GPIO, PWM | |
| 45 | 45 | PL4 | GPIO, PWM | |
| 46 | 46 | PL3 | GPIO, PWM | |
| 47 | 47 | PL2 | GPIO | |
| 48 | 48 | PL1 | GPIO | |
| 49 | 49 | PL0 | GPIO | |
| 50 | 50 | PB3 | GPIO, SPI_MISO (default) | |
| 51 | 51 | PB2 | GPIO, SPI_MOSI (default) | |
| 52 | 52 | PB1 | GPIO, SPI_SCK (default) | |
| 53 | 53 | PB0 | GPIO, SPI_CS (default) | SPI chip select. Keep it an OUTPUT when using SPI, or SPI can stop working. |
| GND | — | |||
| GND | — |
Questions
Which pins are I2C on the Arduino Mega 2560 R3?
SDA is SDA 20 and SCL is SCL 21 (the defaults of the Arduino Wire library). Only certain pins support I2C in hardware, so use these unless you know your core allows others.
Which Arduino Mega 2560 R3 pins should I avoid?
TX0→1, RX0←0 (USB serial link).
Is the Arduino Mega 2560 R3 5 V tolerant?
The Arduino Mega 2560 R3 runs at 5 V, so 5 V sensors connect directly. 3.3 V-only parts need a level shifter.
Which pins can read analog voltage on the Arduino Mega 2560 R3?
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, from 0 to 5 V.
How do I upload code to the Arduino Mega 2560 R3?
In the Arduino IDE pick the board arduino:avr:mega (core arduino:avr).
Wiring guides for the Arduino Mega 2560 R3
Step-by-step wiring, voltage checks and test code for the most used parts:
BME280 BMP280 DHT22 DHT11 HC-SR04 SSD1306 OLED MPU6050 DS18B20 WS2812B LED strip SG90 servo Relay module HC-SR501 PIR LCD 1602 I2C INA219 VL53L0X BH1750 MAX30102 RC522 RFID NEO-6M GPS Capacitive soil moisture sensor ADS1115 TM1637 28BYJ-48 stepper L298N Potentiometer Push button LED Joystick module SD card module AHT20
Compare
Arduino Uno R3 vs Arduino Mega 2560 R3
Learn the basics
Lesson: What is a microcontroller? Lesson: Hardware basics for software developers Lesson: GPIO: pins in and out Pinout GPIO Logic level (HIGH and LOW) Arduino Bootloader
Check your wiring with BoardPilot
BoardPilot shows this board in 3D, flags risky pins as you wire, and flashes it safely with a backup first.
Download BoardPilotSources
- Arduino MEGA 2560 Rev3 Eagle design files, Board outline; header pads and nets (POWER, ADCL, ADCH, JP6, PWML, COMMUNICATION, XIO); RN1 10k pull-ups on SDA/SCL
- Arduino Mega 2560 Rev3 datasheet (A000067), Connector pinouts; IOREF connected to 5V; VIN 7-12 V
- Arduino Mega 2560 Rev3 full pinout (A000067)
- Microchip ATmega640/1280/1281/2560/2561 datasheet, 1 Pin Configurations; 13.3 Alternate Port Functions; 15 External Interrupts; 26 ADC
- arduino/ArduinoCore-avr variants/mega/pins_arduino.h, Arduino pin to port table, PWM timers, SPI/I2C defaults, A0 = 54
- arduino/ArduinoCore-avr boards.txt, USB VID/PID, upload protocol wiring at 115200
- Board data file and source notes on GitHub