The Arduino mega2560 is a microcontroller that is based on the ATmega2560 microcontroller. Arduino mega2560 is an 8-bit AVR Architecture based MCU from ATMEL. It is available in a 100-pin Quad Flat Package.
Arduino Uno, Arduino Nano, and Arduino Micro all is good picks for projects which require less memory to store the program. However, when we get into more complex projects that require large amounts of memory and a large set of I/O interfaces, the Arduino Mega 2560 Rev3 comes into the scene.
The Arduino mega2560 is designed and developed to provide more input-output lines consisting of both analog i/o lines and digital i/o lines. It also needs more flash memory and more RAM when compared to UNO.
Arduino mega 2560 Board Layout
The Arduino mega board consists of 54 digital input/output pins from which 15 pins are Pulse Width Modulation pins, 16 analog inputs. It also has 4 serial ports, one SPI, and one I2C communication protocol, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button.
Voltage Converter
The voltage regulator is used to convert the input voltage to 5 volts. Its primary work is to control the input voltage in order to prevent the board from any damage.
Crystal Oscillator
The Crystal oscillator available on the Arduino mega2560 board has a frequency of 16MHz. It provides the clock signal to the microcontroller. Its work is to provide basic timing and control to the board.
Reset Button
The RESET button is used to Reset the board, and it is recommended to press it each time we flash some code to the board.
USB B port
The USB B port is used to plug in the USB cable. This port is used to power the device from the 5V supply and allows us to connect the board to the computer.
Arduino mega2560 Specifications
MCU | ATmega2560 |
USB Connector | USB-B |
In-build LED | 13 |
Digital I/O Pins | 54 |
Analog input pins | 16 |
PWM pins | 15 |
UART | Yes, 4 |
I2C | Yes |
SPI | Yes |
Clock Speed | 16 MHz |
Flash Memory | 256 KB (8 KB of this used by bootloader) |
SRAM | 8 KB |
EEPROM | 4 KB |
Digital IO Pins | 54 (of which 15 can produce PWM) |
Analog Input Pins | 16 |
I/O Voltage | 5V |
Input voltage (nominal) | 7-12V |
DC Current per I/O Pin | 20 mA |
Supported battery | 9V battery |
Power Supply Connector | Barrel Plug |
Weight | 37 g |
Width | 53.3 mm |
Length | 101.5 mm |
Pinout OF Arduino Mega2560
Let us now go through the pin description of the Arduino mega2560.
Digital Pins
The Arduino mega2560 has the most number of digital pins in the Arduino family and it is one of the reasons why it is called Arduino Mega. These 54 digital pins can only read two values i,e. High or Low. When there will be an input voltage of 5 volts it will be High and when there is no signal or voltage it will be Low. High and Low are also referred to as 1 for High and 0 for Low.
1 | PE0 | Digital pin 0 |
2 | PE1 | Digital pin 1 |
3 | PE4 | Digital pin 2 |
4 | PE5 | Digital pin 3 |
5 | PG5 | Digital pin 4 |
6 | PE3 | Digital pin 5 |
7 | PH3 | Digital pin 6 |
8 | PH4 | Digital pin 7 |
9 | PH5 | Digital pin 8 |
10 | PH6 | Digital pin 9 |
11 | PB4 | Digital pin 10 |
12 | PB5 | Digital pin 11 |
13 | PB6 | Digital pin 12 |
14 | PB7 | Digital pin 13 |
15 | PJ1 | Digital pin 14 |
16 | PJ0 | Digital pin 15 |
17 | PH1 | Digital pin 16 |
18 | PH0 | Digital pin 17 |
19 | PD3 | Digital pin 18 |
20 | PD2 | Digital pin 19 |
21 | PD1 | Digital pin 20 |
22 | PD0 | Digital pin 21 |
23 | PA0 | Digital pin 22 |
24 | PA1 | Digital pin 23 |
25 | PA2 | Digital pin 24 |
26 | PA3 | Digital pin 25 |
27 | PA4 | Digital pin 26 |
28 | PA5 | Digital pin 27 |
29 | PA6 | Digital pin 28 |
30 | PA7 | Digital pin 29 |
31 | PC7 | Digital pin 30 |
32 | PC6 | Digital pin 31 |
33 | PC5 | Digital pin 32 |
34 | PC4 | Digital pin 33 |
35 | PC3 | Digital pin 34 |
36 | PC2 | Digital pin 35 |
37 | PC1 | Digital pin 36 |
38 | PC0 | Digital pin 37 |
39 | PD7 | Digital pin 38 |
40 | PG2 | Digital pin 39 |
41 | PG1 | Digital pin 40 |
42 | PG0 | Digital pin 41 |
43 | PL7 | Digital pin 42 |
44 | PL6 | Digital pin 43 |
45 | PL5 | Digital pin 44 |
46 | PL4 | Digital pin 45 |
47 | PL3 | Digital pin 46 |
48 | PL2 | Digital pin 47 |
49 | PL1 | Digital pin 48 |
50 | PL0 | Digital pin 49 |
51 | PB3 | Digital pin 50 |
52 | PB2 | Digital pin 51 |
53 | PB1 | Digital pin 52 |
54 | PB0 | Digital pin 53 |
Analog Pins
Arduino Mega has 16 analog pins. These pins also get values in contrast to digital pins that receive only two values HIGH and LOW. These analog pins use an analog-to-digital converter (ADC). These pins can act as analog inputs but can also function as digital inputs or digital outputs whenever needed.
These analog pins accept input in the form of analog signals and return values that range between 0 to 1023. The Arduino Mega has a 10-bit Analog to Digital converter or 210 resolution which produces a total of 1024 values i,e. 0 to 1023.
1 | PF0 | Analog pin 0 |
2 | PF1 | Analog pin 1 |
3 | PF2 | Analog pin 2 |
4 | PF3 | Analog pin 3 |
5 | PF4 | Analog pin 4 |
6 | PF5 | Analog pin 5 |
7 | PF6 | Analog pin 6 |
8 | PF7 | Analog pin 7 |
9 | PK0 | Analog pin 8 |
10 | PK1 | Analog pin 9 |
11 | PK2 | Analog pin 10 |
12 | PK3 | Analog pin 11 |
13 | PK4 | Analog pin 12 |
14 | PK5 | Analog pin 13 |
15 | PK6 | Analog pin 14 |
16 | PaK7 | Analog pin 15 |
Vin
It is the amount of input DC voltage that is required to operate the device. It is also called the primary voltage for ICs present on the Arduino board. The Vcc voltage value can be negative or positive to the GND pin.
1 | AVCC(100) | VCC |
2 | VCC(10) | VCC |
3 | VCC(31) | VCC |
4 | VCC(61) | VCC |
5 | VCC(80) | VCC |
GND(ground)
There are a total of 7 ground pins available in Arduino mega.
S.No | Pin Name | Mapped Pin Name |
1 | GND(11) | GND |
2 | GND(32) | GND |
3 | GND(64) | GND |
4 | GND(81) | GND |
5 | GND(99) | GND |
Communication Pins of Arduino Mega2560
UART Pins
UART stands for Universal Asynchronous Receiver and Transmitter.The UART pins available on the arduino mega board are 0, 1, 14, 15, 16, 17, 18, 19. Each UART serial port comes with two pins RX and TX. TX is used for transmitting the data and RX is used for receiving the data.
S.No | Pin Name | Mapped Pin Name |
1 | PE0 ( RXD0/PCINT8 ) | Digital pin 0 (RX0) |
2 | PE1 ( TXD0 ) | Digital pin 1 (TX0) |
3 | PD2 ( RXDI/INT2 ) | Digital pin 19 (RX1) |
4 | PD3 ( TXD1/INT3 ) | Digital pin 18 (TX1) |
5 | PH0 ( RXD2 ) | Digital pin 17 (RX2) |
6 | PH1 ( TXD2 ) | Digital pin 16 (TX2) |
7 | PJ0 ( RXD3/PCINT9 ) | Digital pin 15 (RX3) |
8 | PJ1 ( TXD3/PCINT10 ) | Digital pin 14 (TX3) |
SPI Pins
It stands for Semi Peripheral Interface. The SPI pins available on arduino mega boards are 50, 51, 52, and 53. These pins are used to communicate with one or more peripheral devices quickly.
There are 3 common lines to all the peripheral devices which are:-
- SCK– It stands for Serial Clock. These are the clock pulses that are used to synchronize the transfer of data.
- MISO– It stands for Master Input/ Slave Output. This data line in the MISO pin is used to send the data to the master.
- MOSI– It stands for Master Output/ Slave Input. This line is used for sending data to the peripherals or slaves.
It also have one unique line used by master which is:-
- SS– It stands for slave select. It is used by the master device to select the slave with which it wants to establish the connection. It acts as the enable line. When a device’s Slave Select pin value is LOW, it can communicate with the master. When it’s value is HIGH, it ignores the master.
S.No | Pin Name | Mapped Pin Name |
1 | PB0 ( SS/PCINT0 ) | Digital pin 53 (SS) |
2 | PB1 ( SCK/PCINT1 ) | Digital pin 52 (SCK) |
3 | PB2 ( MOSI/PCINT2 ) | Digital pin 51 (MOSI) |
4 | PB3 ( MISO/PCINT3 ) | Digital pin 50 (MISO) |
I2C Pins
It stands for inter – integrated circuits. I2C is a two-wire serial communication protocol. It uses two lines for sending and receiving data which are:-
Serial Clock Pin or SCL.
This pin is used to transfer the clock data. It usually synchronizes the sharing of data between two devices. It is also called the clock line.
Serial Data Pin or SDA.
This pin is used by the slave and master devices to send and receive the data. This is the reason it is called the Data Line.
S.No | Pin Name | Mapped Pin Name |
1 | PD0 ( SCL/INT0 ) | Digital pin 21 (SCL) |
2 | PD1 ( SDA/INT1 ) | Digital pin 20 (SDA) |
PWM Pins
It stands for Pulse Width Modulation. There are 15 PWM pins present on the arduino mega board from the set of digital pins. The PWM pins are Starting from digital pin 2 to digital pin 13 and pin 44, 45, and 46.Every PWM pin can generate the PWM signal of 23 bit resolution.
S.No | Pin Name | Mapped Pin Name |
1 | PE4 ( OC3B/INT4 ) | Digital pin 2 (PWM) |
2 | PE5 ( OC3C/INT5 ) | Digital pin 3 (PWM) |
3 | PG5 ( OC0B ) | Digital pin 4 (PWM) |
4 | PE3 ( OC3A/AIN1 ) | Digital pin 5 (PWM) |
5 | PH3 ( OC4A ) | Digital pin 6 (PWM) |
6 | PH4 ( OC4B ) | Digital pin 7 (PWM) |
7 | PH5 ( OC4C ) | Digital pin 8 (PWM) |
8 | PH6 ( OC2B ) | Digital pin 9 (PWM) |
9 | PB4 ( OC2A/PCINT4 ) | Digital pin 10 (PWM) |
10 | PB5 ( OC1A/PCINT5 ) | Digital pin 11 (PWM) |
11 | PB6 ( OC1B/PCINT6 ) | Digital pin 12 (PWM) |
12 | PB7 ( OC0A/OC1C/PCINT7 ) | Digital pin 13 (PWM) |
13 | PL5 ( OC5C ) | Digital pin 44 (PWM) |
14 | PL4 ( OC5B ) | Digital pin 45 (PWM) |
15 | PL3 ( OC5A ) | Digital pin 46 (PWM) |
External Interrupts:-
External interrupts of arduino mega can be formed by using 6 pins which are :-
- interrupt 0(0)
- interrupt 1(3)
- interrupt 2(21)
- interrupt 3(20)
- interrupt 4(19)
- interrupt 5(18)
These external interrupt pins can be used to trigger an interrupt on a low value, a rising or falling edge, or a change in value.
S.No | Pin Name | Mapped Pin Name |
1 | PE0 ( PCINT8 ) | Digital pin 0 |
2 | PE5 ( INT5 ) | Digital pin 3 |
3 | PD3 ( TXD1/INT3 ) | Digital pin 18 (TX1) |
4 | PD2 ( RXDI/INT2 ) | Digital pin 19 (RX1) |
5 | PD1 ( SDA/INT1 ) | Digital pin 20 (SDA) |
6 | PD0 ( SCL/INT0 ) | Digital pin 21 (SCL) |
ICSP Header
ICSP stands for In-Circuit Serial Programming. This pin is used to program the firmware of the arduino board.
There are 6 ICSP available on arduino mega boards.
S.No | Pin Name | Mapped Pin Name |
1 | PB2 ( MOSI/PCINT2 ) | Digital pin 51 (MOSI) |
2 | PB3 ( MISO/PCINT3 ) | Digital pin 50 (MISO) |
3 | PB5 ( OC1A ) | Digital pin 11 |
4 | PB6 ( OC1B) | Digital pin 12 |
5 | PB7 ( OC0A/OC1C ) | Digital pin 13 |
6 | PH6 ( OC2B ) | Digital pin 9 |
Frequently Asked Questions:-
- Does Arduino Mega support WIFI?
No, the arduino mega does not come with in-built wi-fi.
- Does Arduino Mega support multithreading?
No, arduino mega does not support multithreading.