Datasheet
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button
to shields which block the one on the board.
The Arduino Mega2560 has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega2560 provides four hardware
UARTs for TTL (5V) serial communication. An ATmega16U2 (ATmega 8U2 on the revision 1
and revision 2 boards) on the board channels one of these over USB and provides a virtual
com port to software on the computer (Windows machines will need a .inf file, but OSX and
Linux machines will recognize the board as a COM port automatically. The Arduino software
includes a serial monitor which allows simple textual data to be sent to and from the board.
The RX and TX LEDs on the board will flash when data is being transmitted via the
ATmega8U2/ATmega16U2 chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).
A SoftwareSerial library allows for serial communication on any of the Mega2560's digital
pins.
The ATmega2560 also supports TWI and SPI communication. The Arduino software includes
a Wire library to simplify use of the TWI bus; see the documentation for details. For SPI
communication, use the SPI library.
The Arduino Mega can be programmed with the Arduino software (download). For details,
see the reference and tutorials.
The ATmega2560 on the Arduino Mega comes preburned with a bootloader that allows you
to upload new code to it without the use of an external hardware programmer. It
communicates using the original STK500 protocol (reference, C header files).
You can also bypass the bootloader and program the microcontroller through the ICSP (In-
Circuit Serial Programming) header; see these instructions for details.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is available in
the Arduino repository. The ATmega16U2/8U2 is loaded with a DFU bootloader, which can
be activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near the map of
Italy) and then resetting the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to ground,
making it easier to put into DFU mode. You can then use Atmel's FLIP software (Windows)
or the DFU programmer (Mac OS X and Linux) to load a new firmware. Or you can use the
ISP header with an external programmer (overwriting the DFU bootloader). See this user-
contributed tutorial for more information.
Rather then requiring a physical press of the reset button before an upload, the Arduino
Mega2560 is designed in a way that allows it to be reset by software running on a connected
computer. One of the hardware flow control lines (DTR) of the ATmega8U2 is connected to
the reset line of the ATmega2560 via a 100 nanofarad capacitor. When this line is asserted
(taken low), the reset line drops long enough to reset the chip. The Arduino software uses this
capability to allow you to upload code by simply pressing the upload button in the Arduino
environment. This means that the bootloader can have a shorter timeout, as the lowering of
DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the Mega2560 is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from software (via