Professional Documents
Culture Documents
Explicacion Arduino PDF
Explicacion Arduino PDF
Explicacion Arduino PDF
Overview
The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 (datasheet). It has 54 digital input/output
pins (of which 14 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal
oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support
the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to
get started. The Mega is compatible with most shields designed for the Arduino Duemilanove or Diecimila.
Schematic: arduino-mega2560-schematic.pdf
Summary
Microcontroller ATmega2560
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 14 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 256 KB of which 8 KB used by bootloader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz
Power
The Arduino Mega can be powered via the USB connection or with an external power supply. The power source is selected
automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be
connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be inserted in
the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin may supply
less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.
The Mega2560 differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it
features the Atmega8U2 programmed as a USB-to-serial converter.
5V. The regulated power supply used to power the microcontroller and other components on the board. This can come
either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V supply.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
Memory
The ATmega2560 has 256 KB of flash memory for storing code (of which 8 KB is used for the bootloader), 8 KB of SRAM
and 4 KB of EEPROM (which can be read and written with the EEPROM library).
Serial: 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 ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt
3), and 21 (interrupt 2). These pins can be configured to trigger an interrupt on a low value, a rising or falling edge,
or a change in value. See the attachInterrupt() function for details.
PWM: 0 to 13. Provide 8-bit PWM output with the analogWrite() function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI communication using the SPI library.
The SPI pins are also broken out on the ICSP header, which is physically compatible with the Uno, Duemilanove and
Diecimila.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the
pin is LOW, it's off.
I 2 C: 20 (SDA) and 21 (SCL). Support I 2C (TWI) communication using the Wire library (documentation on the
Wiring website). Note that these pins are not in the same location as the I 2C 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.
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.
Communication
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 ATmega8U2
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 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 I2C (TWI) and SPI communication. The Arduino software includes a Wire library to
simplify use of the I2C bus; see the documentation on the Wiring website for details. For SPI communication, use the SPI
library.
Programming
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 ATmega8U2 firmware source code is available in the Arduino repository. The ATmega8U2 is loaded with a DFU
bootloader, which can be activated by connecting the solder jumper on the back of the board (near the map of Italy) and
then resetting the 8U2. 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.
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 USB). For the following half-second or so, the bootloader is
running on the Mega2560. While it is programmed to ignore malformed data (i.e. anything besides an upload of new
code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the
board receives one-time configuration or other data when it first starts, make sure that the software with which it
communicates waits a second after opening the connection and before sending this data.
The Mega2560 contains a trace that can be cut to disable the auto-reset. The pads on either side of the trace can be
soldered together to re-enable it. It's labeled "RESET-EN". You may also be able to disable the auto-reset by connecting a
110 ohm resistor from 5V to the reset line; see this forum thread for details.
The Mega2560 is designed to be compatible with most shields designed for the Uno, Diecimila or Duemilanove. Digital
pins 0 to 13 (and the adjacent AREF and GND pins), analog inputs 0 to 5, the power header, and ICSP header are all in
equivalent locations. Further the main UART (serial port) is located on the same pins (0 and 1), as are external interrupts
0 and 1 (pins 2 and 3 respectively). SPI is available through the ICSP header on both the Mega2560 and Duemilanove /
Diecimila. Please note that I 2C is not located on the same pins on the Mega (20 and 21) as the Duemilanove / Diecimila
(analog inputs 4 and 5).
Arduino Mega 2560 Reference Design
TM
Reference Designs ARE PROVIDED "AS IS" AND "WITH ALL FAULTS". Arduino DISCLAIMS ALL OTHER WARRANTIES, EXPRESS OR IMPLIED,
REGARDING PRODUCTS, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
Arduino may make changes to specifications and product descriptions at any time, without notice. The Customer must not
rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined." Arduino reserves
these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them.
The product information on the Web Site or Materials is subject to change without notice. Do not finalize a design with this information.
IC1
3 4 +5V
IN OUT
2
+5V
RN1A 10K
8
MC33269ST-5.0T3 +5V
1
RN1B 10K
RN1C 10K
+5V
22p
22p
RESET
C16
C14
GND +5V 1 JP1
3 VIN IC2 C1 XT1 XTAL1
3 GREEN
MC33269D-5.0 RN3C 1k 1 JP2
3
ON
2
1
+5V
GND
GND
D1
16MHz
16MHz
22p
22p
22p
GND
3 2 3 6
VI VO
C17
C15
M7 ICSP SCL 1 JP3
Q1
Q2
C2 ADJ SDA
1
1
PC1 PC2
+
YELLOW
RN3D 1k GND (SCK) PB1 3 4 PB2 (MOSI) 1 JP4
1
47u 47u L
GND
100n 5 4 RESET 5 6
R1 74 7 8
(AD4)PA4
1M XTAL1R 34 75 PA3 29 PA7 9 10 PA6 28
XTAL1 (AD3)PA3
76 PA2 27 PA5 11 12 PA4 26
(AD2)PA2
16MHz XTAL1 AREF 98 77 PA1 25 PA3 13 14 PA2 24
AREF (AD1)PA1
100 78 PA0 23 PA1 15 16 PA0 22
AVCC (AD0)PA0
27R
+5V
R3
99
AGND +5V
AREF 26 PB7 pwm AREF 8
(OC0A/OC1C/PCINT7)PB7
C3 25 PB6 pwm GND 7
(OC1B/PCINT6)PB6
C4 C5 10 24 PB5 pwm 6
VCC (OC1A/PCINT5)PB5 13
100n C6 31 23 PB4 pwm 5 ICSP1
VCC (OC2A/PCINT4)PB4 12
100n 100n 61 22 PB3 (MISO) 4 MISO2 1 2
VCC (MISO/PCINT3)PB3 11
100n 80 21 PB2 (MOSI) 3 SCK2 3 4 MOSI2
VCC (MOSI/PCINT2)PB2 10
GND 11 20 PB1 (SCK) PH6 pwm 2 RESET2 5 6
GND (SCK/PCINT1)PB1 9
PB0 PH5
8 RN5A
32 GND 19 pwm 1 8 1 2
1
(SS/PCINT0)PB0
62 GND ICSP
81 60 PC7 PWMH RESET-EN
GND (A15)PC7
PC6 GND IC4
10K
(A14)PC6
59 GND
GND 58 PC5 21
(A13)PC5 (PCINT7/OC0A/OC1C)PB7
57 PC4 20
(A12)PC4 (PCINT6)PB6
56 PC3 RESET2 24 19 DTR RESET
(A11)PC3 C8 RESET(PC1/DW) (PCINT5)PB5
55 PC2 18
(A10)PC2 100n (T1/PCINT4)PB4
C7
100n
XIOL 54 PC1 Y2 17 MISO2
53 PB0 (SS) (A9)PC1 X2 F1 (PD0/MISO/PCINT3)PB3
1 2 (SCK) PB1 52 PL7 42
PL7 (A8)PC0
53 PC0 XVCC USBVCC XT2 2
XTAL2(PC0) (PDI/MOSI/PCINT2)PB2
16 MOSI2
51 PB2 (MOSI) 22R
8 RN2A
(MISO) PB3 50 PL6
GND
3 4 41 1 1 R2 15 SCK2
49 PL0 PL1 48 PL5 PL6
PD7 TXD3 14 500mA (SCLK/PCINT1)PB1
5 6 40 50 8 2 D- RD- 1M XT1 XT1R 1 14
USB
pwm PL5(OC5C) (T0)PD7 XTAL1 (SS/PCINT0)PB0
47 PL2 7 8 PL3 46 PL4 pwm 39 49 RXD3 7 15 3 D+ RD+ 16MHz
PL4(OC5B) (T1)PD6 22R
5 RN2D
P$2
P$1
45 PL4 9 10 PL5 44 PL3 pwm 38 48 TXD2 6 16 4 4
PL3(OC5A) (XCK1)PD5 +5V
27R
43 PL6 PL7 42 PL2 RXD2 17
R4
11 12 37 47 5 2 7 32 22
USB boot En
PL2(T5) (ICP1)PD4 COMMUNICATION AVCC (INT4/ICP1/CLK0)PC7
41 PG0 13 14 PG1 40 PL1 36 46 TXD1 4 18 23
PGB1010604
UGND
PL1(ICP5) (TXD1/INT3)PD3 RN2B 22R (OC1A/PCINT8)PC6
UBOOT
39 PG2 PD7 38 PL0 RXD1 19
USHIELD P$2
P$1
15 16 35 45 3 3 6 25
PGB1010604
2
PL0(ICP4) (RXD1/INT2)PD2 (PCINT9/OC1B)PC5
44 SDA 2 20 RN2C 22R 4 26 GND
(SDA/INT1)PD1 VCC (PCINT10)PC4
ADC15 SCL 21
Z1
Z2
8 82 43 1 3 5
PK7(ADC15/PCINT23) (SCL/INT0)PD0 GND (AIN2/PCINT11)PC2
7 ADC14 83
1
ADC13 PK6(ADC14/PCINT22) pwm
6 84 9 PH4 8 7 13
ADC12 PK5(ADC13/PCINT21) (CLKO/ICP3/INT7)PE7 pwm (CTS/HWB/AIN6/TO/INT7)PD7
5 85 8 PH3 7 6 VUCAP 27 12
ADC11 PK4(ADC12/PCINT20) (T3/INT6)PE6 pwm UCAP (RTS/AIN5/INT6)PD6 +5V
ADCH 4 86 7 PE5 pwm PE3 6 5 BLM21 USBVCC 31 11 TXL 3 6
ADC10 PK3(ADC11/PCINT19) (OC3C/INT5)PE5 pwm UVCC (XCK/AIN4/PCINT12)PD5
3 87 6 PE4 pwm PG5 5 4 RD- 30 10 RXL RN4C 1k
ADC9 PK2(ADC10/PCINT18) (OC3B/INT4)PE4 pwm D- (INT5/AIN3)PD4
2 88 5 PE3 pwm PE5 4 3 PWML 1 8 1u RD+ 29 9 M8RXD
ADC8 PK1(ADC9/PCINT17) (OC3A/AIN1)PE3 pwm L1 D+ (TXD1/INT3)PD3
1 89 4 PE4 3 2 RN3A 1k C10 UGND 28 8 M8TXD
PK0(ADC8/PCINT16) (XCK0/AIN0)PE2 pwm UGND (RXD1/AIN1/INT2)PD2
3 PE1 (TX0) PE1 2 1 2 7 7
(TXD0)PE1
PE0 PE0 pwm 100n (AIN0/INT1)PD1 TX
79
PJ7 (RXD0/PCIN8)PE0
2 (RX0) 1 0 RN3B 1k C9
EXP
PAD (OC0B/INT0)PD0
6 YELLOW
69
+5V+3V3 PJ6(PCINT15) ADC7
68
PJ5(PCINT14) (ADC7/TDI)PF7
90 8 1 2 ATMEGA8U2-MU
67 91 ADC6 7 GND
PJ4(PCINT13) (ADC6/TDO)PF6 ADC5 GROUND
POWER 66 92 6 4 5 4 5
PJ3(PCINT12) (ADC5/TMS)PF5 ADC4
1 65
PJ2(XCK3/PCINT11) (ADC4/TCK)PF4
93 5 ADCL RN5D 10K 2 7 RX RN4D 1k
2 TXD3 64 94 ADC3 4 4 5 GND PE0 M8RXD
PJ1(TXD3/PCINT10) (ADC3)PF3 RN4B 1k YELLOW
3 RXD3 63 95 ADC2 3
PJ0(RXD3/PCINT9) (ADC2)PF2 RN1D 10K
4 96 ADC1 2
(ADC1)PF1 ADC0 M8TXD
5 27 97 1 PE1
pwm PH7(T4) (ADC0)PF0
6 PH6 18 1 8
VIN pwm PH6(OC2B)
PH5 17 1 PG5 pwm RN4A 1k
pwm PH5(OC4C) (OC0B)PG5
GND PH4 16 29
pwm PH4(OC4B) (TOSC1)PG4
PH3 15 28
PH3(OC4A) (TOSC2)PG3
14 70 PG2
PH2(XCK2) (ALE)PG2 +5V
TXD2 13 52 PG1 VIN
PH1(TXD2) (RD)PG1
RXD2 12 51 PG0
6
ATMEGA1280-16AU 7 1
5 +3V3 6 2
8
RESET
GND
4 2 LM358D LM358D
3
3 1 C11
100n C12 GND
7
TS42 100n
4
RESET GATE_CMD
2
100n C13
3
EN
2 4
GND NC/FB
T2
FDN340P GND
GND