Arduino Mega Tutorial [Pinout]

In this tutorial you learn everything you have to know about the Arduino Mega:

  • Technical datasheet
  • What is the pinout of the Mega?
  • What is the best power supply for this microcontroller?
  • How to reduce the Arduino Mega power consumption?
  • Advantages and Disadvantages of the Arduino Mega.
  • Compare the Mega to other Arduino and ESP8266 based microcontroller.
Microcontroller Comparison

Table of Contents

Arduino Mega Datasheet

The Arduino Mega is a microcontroller board, based on the ATmega2560P microcontroller by Atmel. The ATmega2560P comes with builtin bootloader which makes it very easy to flash the board with your code. Like all Arduino boards, you can program the software running on the board using a language derived from C and C++. The easiest development environment is the Arduino IDE.

The following table contains the datasheet of the microcontroller board:

BoardArduino MEGA R3
MicrocontrollerATmega2560
ProcessorAVR 8-bit
Operating Voltage5V
Minimum Operating Voltage2.7V
Maximum Operating Voltage5.5V
Arduino IDE BoardArduino/Genuino Mega or Mega 2560
Power Supply via VIN,VCC7V...12V
Digital I/O Pins (with PWM)54 (15)
Analog Input Pins16
Resolution ADC10 bit (0...1023)
Analog Output Pins0
SPI/I2C/I2S/UART1/1/0/4
Max DC Current per I/O Pin20 mA
Max DC Current per 3V Pin50 mA
Flash Memory256 KB
SRAM8 KB
EEPROM4096 bytes
Clock Speed16 MHz
Length x Width102mm x 53mm
Fits on standard breadboardno
WIFIno
Bluetoothno
Touch sensorno
CANno
Ethernet MAC Interfaceno
Temperature Sensorno
Hall effect sensorno
Power jackyes
USB connectionyes
Battery Connectionno
ProgrammableArduino IDE
5V Voltage RegulatorLD1117S50CTR
Output Voltage5V
Maximum Input Voltage15V
Minimum Input Voltage7V
Maximum Output Current800mA
Maximum Voltage Dropout1.1V @ 800mA
Typical Quiescent Current5mA
3.3V Voltage RegulatorLP2985-33DBVR
Output Voltage3.3V
Maximum Input Voltage16V
Minimum Input Voltage3.9V
Maximum Output Current150mA
Maximum Voltage Dropout350mV @ 150mA
Typical Quiescent Current1.5mA
Power Consumption @ 9V
Reference Empty Script [mA]73.19
Reduce Clock Speed [mA]61.76
Low Power Mode [mA]26.87
Power Consumption @ 3.3V
Reduce Clock Speed [mA]16.74
Low Power Mode [mA]11.85

Do you want to compare the datasheet of different microcontroller boards like Arduino Uno, Arduino Nano, ESP8266 Node MCU and WeMos D1 Mini? Follow this Link for the comparison.

If you do not already have an Arduino Mega, you can buy one from the following links. I get commissions for purchases made through links in this table.

ComponentAmazon LinkAliExpress Link
Arduino MegaAmazonAliExpress

Arduino Mega Pinout

Arduino Mega Pinout

Because the Mega is the biggest Arduino microcontroller, this beast has the highest number of pins and is therefore suitable for large projects where a lot of devices have to be connected to the microcontroller.

The Arduino Mega has in total one 3.3V pin and four 5V pins, which are able to provide a current up to 50 mA. The VIN power pin can also serve as power supply for the microcontroller with a voltage range between 7V-12V.

If you want to close the circuit, there are in total five ground pins available, which are all connected.

The Mega has 16 analog pins connected internally with a 10-bit analog-to-digital converter (ADC). Therefore the analog voltage is represented by 1024 digital levels. It is also possible to use the analog pins to write a digital signal with the function digitalWrite(Ax).

Also there are a bunch of digital pins available. In total the microcontroller has 54 digital I/O pins and 15 are able to produce a PWM signal. The maximum DC current per digital pin is 40 mA.

The Arduino Mega has all communication standards on board:

Arduino Mega Power Supply

The Arduino Mega power supply depends on the different voltage levels of the microcontroller. Therefore we have to know which electronic components are relevant for the voltage levels. The following picture provides an overview of the voltage levels and the maximum currents of the Arduino Mega.

Arduino Mega voltage current overview

The main component of the Arduino Mega is the microprocessor ATmega2560. The following table shows the minimum, operation and maximum voltage.

MicrocontrollerMinimum VoltageTypical VoltageMaximum Voltage
ATmega25602.7V5V5.5V

Because the operation voltages is 5V, there this one build in voltage regulator that provide a stable 5V and also an additional voltage regulator for the 3.3V output voltage of the corresponding pin.

Microcontroller Datasheet eBook

The 35 pages Microcontroller Datasheet Playbook contains the most useful information of 14 Arduino, ESP8266 and ESP32 microcontroller boards.

Arduino Mega Voltage Regulators

The following table shows the most important technical details of the two voltage regulators regarding the power supply.

Voltage RegulatorOutput VoltageMaximum Input VoltageMaximum Output Current
LD1117S50CTR5V15V800mA
LP2985-33DBVR3.3V16V150mA

The LD1117S50CTR provides a stable 5V output for the ATmega2560 and has a maximum input voltage of 15V. But an input voltage between 7V and 12V is recommended to use the Arduino Mega over an extended period of time because otherwise the voltage regulator produces a lot of heat that can damage the microcontroller. Besides a higher input voltage than 12V has no advantage. The maximum output current of the LD1117S50CTR is 800mA.

The Arduino Mega can also be powered via the USB port. There is no need for a voltage regulator because the USB connection is already regulated by the USB output from your PC or laptop. The maximum current draw from the USB connection is therefore reduced to 500mA.

Because the Arduino Mega has 3.3V pins to supply external electrical devices, there is a second voltage regulator build in, that reduces the voltage from 5V to 3.3V. The LP2985-33DBVR has a maximum output current of 150mA but on the official Arduino website, the maximum current is limited to 50mA. In my opinion you should be save to draw a current up to 100mA.

The 5V pin of the Arduino Mega is directly connected to the 5V voltage regulator and supports a maximum current that is defined by the difference of the current provided by the voltage regulator and the current from the ATmega2560.

Maximum Current for I/O Pins

Regarding the data-sheet of the ATmega2560, each I/O port is tested with 20mA. But this does not mean that you can draw 20mA from each pin because the I/O pins are connected to a port register in groups of 7 pins. These port registers have in different combinations also a maximum allowed current.

There are in total 11 port registers with internal pull-up registers and some of them have an analog to digital converter if analog pins are connected to this register. The following picture shows which pin is assigned to which port register.

Arduino Mega Ports

Now we want to know which port register combination has to be considered when there is a maximum allowed current.

The maximum current for the combination of port registers is the following:

  • J0-J7 + A0-A7 + G2 < 200mA
  • C0-C7 + G0-G1 + D0-D7 + L0-L7 < 200mA
  • G3-G4 + B0-B7 + H0-B7 < 200mA
  • E0-E7 + G5 < 100mA
  • F0-F7 + K0-K7 < 100mA

How to Power Arduino Mega: 3 Possibilities

Like the Arduino Uno, you can power your Arduino Mega in three save ways because a voltage regulator provides a regulated and stable voltage for the ATmega2560 microprocessor:

  1. USB cable: The most popular and also the easiest way to power the microcontroller is via USB cable. The standard USB connection delivers 5V and allows you to draw 500mA in total.
  2. DC Power Jack: It is possible to use the DC power Jack as power supply. If you buy a DC power jack, make sure the power adapter of the plug supplies a voltage between 7V and 12V.
  3. VIN Pin: If you use an external power supply like a battery, you can use the VIN pin. The voltage has to be between 7V and 12V. Therefore you are able to power the Uno with an external 9 Volt battery.

You cannot power the board with the barrel jack and VIN GPIO at the same time, because there is a polarity protection diode, connecting between the positive of the barrel jack to the VIN pin, rated at 1A.

You can also power power the Arduino microcontroller from the 5V pin. This is not recommended because you bypass the LD1117S50CTR 5V voltage regulator and have to make sure that the voltage level is stable.

It is not possible to power the Arduino Mega via the 3.3V pin because the voltage regulator prevent a current flow in the opposite direction.

Arduino Mega Power Consumption

The power consumption of the Arduino Mega is obviously dependent on the connected electrical devices and the task that is performed. But when we are interested in the power consumption, most of the times we want to know how to reduce the Arduino Mega power consumption.

The following picture show the power consumption of the Arduino Mega in different setups.

With a 9V power supple, the Arduino Mega has a power consumption of 73.19mA, that is lower than the Arduino Uno with 98.43mA. If you reduce the clock speed, the power consumption decreases to 61.76mA and if you also reduce the power supply from 9V to 3.3V, you can achieve a current draw of 16.74mA.

An other option to reduce the power consumption is to use the Low-Power library from rocketscream. With a 9V power supply, the current consumption is reduced to 26.87mA and you achieve the lowest power consumption for the Arduino Mega of 11.85mA with a 3.3V power supply and the use of the low power mode.

The following example scripts sets Arduino Mega in the deep-sleep mode for 8 seconds with the use of the low power library. I also wrote a step by step tutorial, how to reduce the Arduino power consumption where you also see how to reduce the clock speed.

#include "LowPower.h"

void setup()
{
    // No setup is required for this library
}

void loop() 
{
    // Do something here
    // Example: Read sensor, data logging, data transmission.

    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  
}

You find a full comparison about the power consumption in different power modes of several Arduino, ESP8266 and ESP32 microcontroller boards in my Microcontroller Datasheet eBook.

Arduino Mega Advantages and Disadvantages

Advantages

  • The ability to use a Power Jack as a power supply.
  • The pure amount of 54 digital input pins are for the most projects far more than enough. In comparison the ESP8266 has only 1 analog input pin.

Disadvantages

  • For the Mega there is no build in WiFi. Because most of my projects are related to the IoT sector I use WiFi in almost all my projects.
  • The Mega has only 256 kB of flash memory for the many digital input pins.

Conclusion

The Mega is the biggest Arduino board on the market. If you need a lot of input pins the Arduino Mega has no competitors. Do you have any questions about the Arduino Mega or other boards on the market? Do you use the Mega in a project? If yes than let us know for what project do you use the Mega. Lave a comment below.

7 thoughts on “Arduino Mega Tutorial [Pinout]”

  1. Hello.
    Thanks for the article. Very helpful!
    I was wondering if anybody tried the Low-Power library in practice? It all looks good when lookign at the code but I don’t want to send my Mega into total knock-out and not be able to re-animate 🙂
    Thanks!

    Reply

Leave a Comment