Arduino Mega Tutorial [Pinout]

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?
  • Advantages and Disadvantages of the Arduino Mega.
  • Compare the Mega to other Arduino and ESP8266 based microcontroller.
Microcontroller Comparison

Table of Contents

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:

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.

Arduino Mega R3 Amazon Banggood AliExpress

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.

Microcontroller

Minimum Voltage

Typical Voltage

Maximum Voltage

ATmega2560

2.7V

5V

5.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.

Arduino Mega Voltage Regulators

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

Voltage Regulator

Output Voltage

Maximum Input Voltage

Maximum Output Current

LD1117S50CTR

5V

15V

800mA

LP2985-33DBVR

3.3V

16V

150mA

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

Three possibilities for the Power Supply

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 of course dependent on the connected electrical devices and the task that is performed. But we can get a good basic estimation of the current consumption when we sum up the individual current consumption of the main electronic parts of the microcontroller.

The main electronic part is the ATmega2560 that has a current consumption dependent on the clock cycle, the supply voltage and the power mode. The following table shows the typical and maximum current consumption of the different dependencies.

Mode

Clock Frequency

Supply voltage

Typical current consumption

Maximum current consumption

Active

1MHz

2V

0.5 mA

0.8 mA

Active

4MHz

3V

3.2 mA

5 mA

Active

8MHz

5V

10 mA

14 mA

Idle

1MHz

2V

0.14 mA

0.22 mA

Idle

4MHz

3V

0.7 mA

1.1 mA

Idle

8MHz

5V

2.7 mA

4 mA

The ATmega2560 has also a power-down mode that reduces the current consumption to a minimum.

Mode

WDT

Supply voltage

Typical current consumption

Maximum current consumption

Power-down

enabled

3V

< 0.005 mA

0.015 mA

Power-down

disabled

3V

< 0.001 mA

0.0075 mA

The activation of the power-down mode is easy if you use the Low-Power library from rocketscream. The following example scripts sets Arduino Mega in the deep-sleep mode for 8 seconds.

#include "LowPower.h"

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

void loop() 
{
    // Enter power down state for 8 s with ADC and BOD module disabled
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  
    
    // Do something here
    // Example: Read sensor, data logging, data transmission.
}

From my experience I would power the Arduino Mega with a supply voltage of around 3V, when I try to minimize the power consumption and use a battery as power source. Therefore I assume a current consumption of 3.2mA.

Now I add the current consumption of the three voltage regulators to the consumption of the Arduino Mega. The LP2985 has a current consumption of 0.85mA at 150mA full load and the LD1117S50CTR draws maximal 10mA. Because we do not calculate with the limits of the voltage divider, I would guess a total current consumption of 3.2mA + 0.85mA / 2 + 10mA / 2 = 8.625mA.

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.

6 Responses

Leave A Comment