Arnoldo B. Canales

Arduino Mega 2560 Microcontroller

Please visit the Arduino Board Mega official website.

Figure 1: Arduino Mega 2560 Microcontroller pinout

Input and Output

The Arduino 2560 Mega has 54 digital pins and all of them can be used as input/output by using functions pinMode(), digitalWrite(), and digitalRead(). They operate at 5 volts @ 40ma and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms.

Some pins have specialized functions:

Function Pins
Serial 0: 0 (RX) and 1 (TX)
Serial 1: 19 (RX) and 18 (TX)
Serial 2: 17 (RX) and 16 (TX)
Serial 3: 15 (RX) and 14 (TX)

Used to receive (RX) and transmit (TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 USB-to-TTL Serial chip.

External Interrupts:

Function Pins
interrupt 0 2
interrupt 1 3
interrupt 5 18
interrupt 4 19
interrupt 3 20
interrupt 2 21

These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See function attachInterrupt() for more details.

Pulse Width Modulation or PWM:

2 to 13 and 44 to 46

Provide 8-bit PWM output using function analogWrite().

Serial Peripheral Interface or SPI:

Pins Function
50 MISO (Master In Slave Out) - The Slave line for sending data to the master.
51 MOSI (Master Out Slave In) - The Master line for sending data to the peripherals.
52 SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master.
53 SS (Slave Select) - the pin on each device that the master can use to enable and disable specific devices.

These pins support SPI communication using the SPI library. When a device's Slave Select pin is low, it communicates with the master. When it's high, it ignores the master. This allows you to have multiple SPI devices sharing the same MISO, MOSI, and CLK lines. The SPI pins are also broken out on the ICSP header, which is physically compatible with the Uno, Duemilanove and Diecimila.

LED:

Pin 13

Built-in LED connected to digital pin 13. When the pin has HIGH value (1), the LED is on, when the pin gets LOW (0), the led is off.

Two-Wire Interface or TWI:

20 - SDA - Data Line

21 - SCL - Clock Line

Support TWI communication using the Wire library. Note that these pins are not in the same location as the TWI pins on the Duemilanove or Diecimila. The Mega2560 has 16 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and analogReference() function.

AREF:

Reference Voltage for the analog inputs. Used with analogReference().

Reset:

When LOW the microcontroller gets a cold Reset.

PROJECTS

120x120

 

C# program - Mega 2560.

120x120

 

C# program - Mega 2560. Using debugging LEDs.

120x120

 

Evaluating the Proximity Sensor HC-SR04.

120x120

 

Scrolling characters using the MAX7219.

120x120

 

Basic Handling of an Stepper Motor.

120x120

 

The Camera Slider.