Arduino Mega - Description & Pinout
Surely Arduino UNO is one of the most popular Microcontroller development board for project hobbyist and for some professionals also.
When cheaper boards are available, why choose Arduino Mega? The main reason behind this is the additional features that are built into this board. The first feature is the large I/O system with 16 analog and 54 built-in digital pins supporting USART and other communication modes. Secondly, it has a built-in RTC and other features like an analog comparator, an advanced timer, an interruption of the controller's wake-up mechanism to save more power and a faster speed with a 16MHz crystal clock to get 16 MIBS. It has more than 5 pins for Vcc and Gnd to connect other devices to Arduino Mega.
Other features include JTAG support for programming, debugging, and troubleshooting. With a large FLASH and SRAM memory, this card can easily handle a large system program. It is also compatible with different types of cards such as the high level signal (5V) or the low level signal (3.3V) with I/O reference pin.
The brownouts and watchdog help make the system more reliable and robust. It supports ICSP as well as USB microcontroller programming with PC.
The Arduino Mega 2560 replaces the old Arduino Mega. In general, it will be called without the extension "2560". It is usually used for very complex projects.
Arduino Mega Features
Basic Features
Advance Features
Controller Pins:
RESET: (Reset input) A low level on this pin for longer than the 4 clock cycle will generate a reset. Arduino Mega has inbuilt reset circuit with push button to reset system and this pin can be used by other devices to reset controller.
XTAL1,XTAL2: Crystal (16Mhz) is connected to supply clock for controller with 2 bypass capacitor to ground.
AREF: This pin is used, when we use Adc for analog to digital conversion with external reference voltage for conversion and don’t want to use internal 1.1V or 5v reference.
Digital pins (70):
Digital pins (0-53) + Analog (0-15) = Total Digital I/O pins.
Digital Pins: From 0-53(digital) and 0-15(analog) can also be used as input or output for digital Read/Write Operations by using pinMode() for pin direction, digtalWrite() to write pin and digitalRead() to read pin status.
Example:
Output low signal on Arduino mega boardpinMode(0,OUTPUT);
digitalWrite(0,LOW);
Input read signal on Arduino mega boardpinMode(0,INPUT);
digitalRead(0);
Analog Pins (16):
Analog pins: From 0-15 Pins can be used as Input pin for ADC, if not used than it work as normal digital pin. It can be used by pinMode() for pin direction, analogRead() to read pin status and get digital value for analog signal, care must be taken for internal or external reference voltage selection and Aref pin.
Example :
INPUT analog signal on Arduino mega board
pinMode(0,INPUT);
analogRead(0);
Alternative Pins Function:
I2C Pins:
Hardware Interrupt Pins :
Arduino Mega Schematic Components:
Basic Programme for Arduino Mega 2560
Blinking an LED
void setup()
{
pinMode(13, OUTPUT); // initialize digital pin 13 as an output.
}
void setup()
{
pinMode(3, OUTPUT);
}
void loop()
{
analogWrite(3, brightness); // pwm write on pin 3
++brightness; // brightness is incremented by 1
if (brightness <= 0 || brightness >= 255) {
brightness=0; // brightness limited to 0-255
When cheaper boards are available, why choose Arduino Mega? The main reason behind this is the additional features that are built into this board. The first feature is the large I/O system with 16 analog and 54 built-in digital pins supporting USART and other communication modes. Secondly, it has a built-in RTC and other features like an analog comparator, an advanced timer, an interruption of the controller's wake-up mechanism to save more power and a faster speed with a 16MHz crystal clock to get 16 MIBS. It has more than 5 pins for Vcc and Gnd to connect other devices to Arduino Mega.
Other features include JTAG support for programming, debugging, and troubleshooting. With a large FLASH and SRAM memory, this card can easily handle a large system program. It is also compatible with different types of cards such as the high level signal (5V) or the low level signal (3.3V) with I/O reference pin.
The brownouts and watchdog help make the system more reliable and robust. It supports ICSP as well as USB microcontroller programming with PC.
The Arduino Mega 2560 replaces the old Arduino Mega. In general, it will be called without the extension "2560". It is usually used for very complex projects.
Arduino Mega Features
Basic Features
Microcontroller
|
AVR ATmega 2560 (8bit)
|
Power Supply
|
7-12V (Inbuilt Regulator for Controller)
|
Digital I/O Pins
|
54
|
Analog I/O Pins
|
16
|
Total Digital I/O
|
70 (Digital + Analog)
|
Clock Speed
|
16 MHz (Factory set to 1Mhz)
|
Flash Memory
|
128 KB
|
SRAM
|
8 KB
|
Communication
|
USB (Programming with ATmega 8), ICSP (programming), SPI, I2C and USART
|
Timer
|
2 (8bit) + 4 (16bit) = 6 timer
|
PWM
|
12 (2-16 bit)
|
ADC
|
16 (10 bit)
|
USART
|
4
|
Pin Change Interrupt
|
24
|
Arduino Mega 2560 is also packed with additional features like Analog Comparator, External Interrupt & Software Interrupt, Power Saving Mode, Inbuilt Temperature Sensor, RTC and more.
Arduino Mega Pins
Below is the pin mapping for the Atmega2560. The chip used in Arduino 2560.
Pin Number
|
Pin Name
|
Mapped Pin Name
|
1
|
PG5 ( OC0B )
|
Digital pin 4 (PWM)
|
2
|
PE0 ( RXD0/PCINT8 )
|
Digital pin 0 (RX0)
|
3
|
PE1 ( TXD0 )
|
Digital pin 1 (TX0)
|
4
|
PE2 ( XCK0/AIN0 )
| |
5
|
PE3 ( OC3A/AIN1 )
|
Digital pin 5 (PWM)
|
6
|
PE4 ( OC3B/INT4 )
|
Digital pin 2 (PWM)
|
7
|
PE5 ( OC3C/INT5 )
|
Digital pin 3 (PWM)
|
8
|
PE6 ( T3/INT6 )
| |
9
|
PE7 ( CLKO/ICP3/INT7 )
| |
10
|
VCC
|
VCC
|
11
|
GND
|
GND
|
12
|
PH0 ( RXD2 )
|
Digital pin 17 (RX2)
|
13
|
PH1 ( TXD2 )
|
Digital pin 16 (TX2)
|
14
|
PH2 ( XCK2 )
| |
15
|
PH3 ( OC4A )
|
Digital pin 6 (PWM)
|
16
|
PH4 ( OC4B )
|
Digital pin 7 (PWM)
|
17
|
PH5 ( OC4C )
|
Digital pin 8 (PWM)
|
18
|
PH6 ( OC2B )
|
Digital pin 9 (PWM)
|
19
|
PB0 ( SS/PCINT0 )
|
Digital pin 53 (SS)
|
20
|
PB1 ( SCK/PCINT1 )
|
Digital pin 52 (SCK)
|
21
|
PB2 ( MOSI/PCINT2 )
|
Digital pin 51 (MOSI)
|
22
|
PB3 ( MISO/PCINT3 )
|
Digital pin 50 (MISO)
|
23
|
PB4 ( OC2A/PCINT4 )
|
Digital pin 10 (PWM)
|
24
|
PB5 ( OC1A/PCINT5 )
|
Digital pin 11 (PWM)
|
25
|
PB6 ( OC1B/PCINT6 )
|
Digital pin 12 (PWM)
|
26
|
PB7 ( OC0A/OC1C/PCINT7 )
|
Digital pin 13 (PWM)
|
27
|
PH7 ( T4 )
| |
28
|
PG3 ( TOSC2 )
| |
29
|
PG4 ( TOSC1 )
| |
30
|
RESET
|
RESET
|
31
|
VCC
|
VCC
|
32
|
GND
|
GND
|
33
|
XTAL2
|
XTAL2
|
34
|
XTAL1
|
XTAL1
|
35
|
PL0 ( ICP4 )
|
Digital pin 49
|
36
|
PL1 ( ICP5 )
|
Digital pin 48
|
37
|
PL2 ( T5 )
|
Digital pin 47
|
38
|
PL3 ( OC5A )
|
Digital pin 46 (PWM)
|
39
|
PL4 ( OC5B )
|
Digital pin 45 (PWM)
|
40
|
PL5 ( OC5C )
|
Digital pin 44 (PWM)
|
41
|
PL6
|
Digital pin 43
|
42
|
PL7
|
Digital pin 42
|
43
|
PD0 ( SCL/INT0 )
|
Digital pin 21 (SCL)
|
44
|
PD1 ( SDA/INT1 )
|
Digital pin 20 (SDA)
|
45
|
PD2 ( RXDI/INT2 )
|
Digital pin 19 (RX1)
|
46
|
PD3 ( TXD1/INT3 )
|
Digital pin 18 (TX1)
|
47
|
PD4 ( ICP1 )
| |
48
|
PD5 ( XCK1 )
| |
49
|
PD6 ( T1 )
| |
50
|
PD7 ( T0 )
|
Digital pin 38
|
51
|
PG0 ( WR )
|
Digital pin 41
|
52
|
PG1 ( RD )
|
Digital pin 40
|
53
|
PC0 ( A8 )
|
Digital pin 37
|
54
|
PC1 ( A9 )
|
Digital pin 36
|
55
|
PC2 ( A10 )
|
Digital pin 35
|
56
|
PC3 ( A11 )
|
Digital pin 34
|
57
|
PC4 ( A12 )
|
Digital pin 33
|
58
|
PC5 ( A13 )
|
Digital pin 32
|
59
|
PC6 ( A14 )
|
Digital pin 31
|
60
|
PC7 ( A15 )
|
Digital pin 30
|
61
|
VCC
|
VCC
|
62
|
GND
|
GND
|
63
|
PJ0 ( RXD3/PCINT9 )
|
Digital pin 15 (RX3)
|
64
|
PJ1 ( TXD3/PCINT10 )
|
Digital pin 14 (TX3)
|
65
|
PJ2 ( XCK3/PCINT11 )
| |
66
|
PJ3 ( PCINT12 )
| |
67
|
PJ4 ( PCINT13 )
| |
68
|
PJ5 ( PCINT14 )
| |
69
|
PJ6 ( PCINT 15 )
| |
70
|
PG2 ( ALE )
|
Digital pin 39
|
71
|
PA7 ( AD7 )
|
Digital pin 29
|
72
|
PA6 ( AD6 )
|
Digital pin 28
|
73
|
PA5 ( AD5 )
|
Digital pin 27
|
74
|
PA4 ( AD4 )
|
Digital pin 26
|
75
|
PA3 ( AD3 )
|
Digital pin 25
|
76
|
PA2 ( AD2 )
|
Digital pin 24
|
77
|
PA1 ( AD1 )
|
Digital pin 23
|
78
|
PA0 ( AD0 )
|
Digital pin 22
|
79
|
PJ7
| |
80
|
VCC
|
VCC
|
81
|
GND
|
GND
|
82
|
PK7 ( ADC15/PCINT23 )
|
Analog pin 15
|
83
|
PK6 ( ADC14/PCINT22 )
|
Analog pin 14
|
84
|
PK5 ( ADC13/PCINT21 )
|
Analog pin 13
|
85
|
PK4 ( ADC12/PCINT20 )
|
Analog pin 12
|
86
|
PK3 ( ADC11/PCINT19 )
|
Analog pin 11
|
87
|
PK2 ( ADC10/PCINT18 )
|
Analog pin 10
|
88
|
PK1 ( ADC9/PCINT17 )
|
Analog pin 9
|
89
|
PK0 ( ADC8/PCINT16 )
|
Analog pin 8
|
90
|
PF7 ( ADC7 )
|
Analog pin 7
|
91
|
PF6 ( ADC6 )
|
Analog pin 6
|
92
|
PF5 ( ADC5/TMS )
|
Analog pin 5
|
93
|
PF4 ( ADC4/TMK )
|
Analog pin 4
|
94
|
PF3 ( ADC3 )
|
Analog pin 3
|
95
|
PF2 ( ADC2 )
|
Analog pin 2
|
96
|
PF1 ( ADC1 )
|
Analog pin 1
|
97
|
PF0 ( ADC0 )
|
Analog pin 0
|
98
|
AREF
|
Analog Reference
|
99
|
GND
|
GND
|
100
|
AVCC
|
VCC
|
Controller Pins:
RESET: (Reset input) A low level on this pin for longer than the 4 clock cycle will generate a reset. Arduino Mega has inbuilt reset circuit with push button to reset system and this pin can be used by other devices to reset controller.
XTAL1,XTAL2: Crystal (16Mhz) is connected to supply clock for controller with 2 bypass capacitor to ground.
AREF: This pin is used, when we use Adc for analog to digital conversion with external reference voltage for conversion and don’t want to use internal 1.1V or 5v reference.
Digital pins (70):
Digital pins (0-53) + Analog (0-15) = Total Digital I/O pins.
Digital Pins: From 0-53(digital) and 0-15(analog) can also be used as input or output for digital Read/Write Operations by using pinMode() for pin direction, digtalWrite() to write pin and digitalRead() to read pin status.
Example:
Output low signal on Arduino mega boardpinMode(0,OUTPUT);
digitalWrite(0,LOW);
Input read signal on Arduino mega boardpinMode(0,INPUT);
digitalRead(0);
Analog Pins (16):
Analog pins: From 0-15 Pins can be used as Input pin for ADC, if not used than it work as normal digital pin. It can be used by pinMode() for pin direction, analogRead() to read pin status and get digital value for analog signal, care must be taken for internal or external reference voltage selection and Aref pin.
Example :
INPUT analog signal on Arduino mega board
pinMode(0,INPUT);
analogRead(0);
Alternative Pins Function:
SPI Pins:
Pin 22 - SS, Pin 23 - SCK, Pin 24 - MOSI, Pin 25 – MISO
These pins are used for serial communication with SPI protocol for communication between devices. SPI enable bit must be set to start communication with other devices.
I2C Pins:
Digital pin 20 for SDA and 21 for SCK (Speed 400khz) to enable two wire communication with others devices. Function used are wire.begin() to start I2C conversion, with wire.Read() to read i2c data and wire.Write() to write i2c data.
Example:
I2c master read data from slave
Wire.begin();
Wire.requestFrom(2, 1); //1byte data
Wire.Read();
PWM Pins:
Digital pin 2-13 can be used as PWM output with analogWrite() to write PWM value from 0-255.It’s alternative of DAC for low cost system to get analog signal at output by using filter.
Example:
OUTPUT analog signal on Arduino mega board
pinMode(0,OUTPUT);
analogWrite(0,255);
USART Pins :
Pin 0 – RXD0, pin 1 – TXD0
Pin 19 – RXD1, pin 18 – TXD1
Pin 17 – RXD2, pin 16 – TXD2
Pin 15 – RXD3, pin 14 – TXD3
This pin is used for serial usart communication with pc or other system for data sharing and logging. It is used with serialBegin() to set baud rate setting and start communication with serial.Println() to print array of char on other device output.
Example:
Serial.begin(9600);
Serial.Println(“hello”);
Pinchange Interrupt Pins:
Digital Pin 0,22,23,24,25,10,11,12,13,15,14
Analog Pin 6,7,8,9,10,11,12,13,14,15
This pin is used for pin change interrupt. Enable bit of pinchange interrupt must be set with global interrupt enable.
Example :
pinMode(0, OUTPUT);
pinMode(1, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(1), LOW, CHANGE);
Hardware Interrupt Pins :
Digital pin 18 – 21,2,3 hardware interrupt is used for interrupt services. Hardware interrupt must be enabled with global interrupt enable to get interrupt from other devices.
Example:
pinMode(0, OUTPUT);
pinMode(1, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(1), LOW, LOW);
Arduino Mega Schematic Components:
DC Jack Power Supply :
External Supply for Arduino Mega from range 7-12 volt is given with this port. Arduino Mega R3 has a voltage regulator for 5v and 3.3v supply for Arduino controller and sensor supply.
AVR 2560 :
This is the main controller used to program and run task for the system. This is the brain of the system to control all other devices on board.
ATmega8 :
This controller is used for communication between the main controller and other devices. This controller is programmed for USB communication and serial programming features.
ICSP 1 (ATmega8) and 2 (AVR 2560):
It has features of programming using serial bus with AVR programmer using SPI communication. AVR 2560 is programmed to run the system and ATmega 8 is programmed for serial communication and programming.
Reset :
It has reset circuit with capacitor, button and resistor to reset the controller. A push button is used to get 4 cycle low signal on reset pin to get the controller in reset mode.
Crystal :
It has a crystal circuit with two capacitors and one 16 Mhz crystal for xtal pins 1 and 2 interfacing with avr 2560.
I2C :
It has features of I2C (two wire communication) with an external pull-up resistor.
USART :
It has TXD and RXD pin for serial communication with LED indicator.
Blinking an LED
void setup()
{
pinMode(13, OUTPUT); // initialize digital pin 13 as an output.
}
void loop()
{
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
LED Light Dimmer (PWM)
int brightness = 0; //pwm value
{
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
LED Light Dimmer (PWM)
int brightness = 0; //pwm value
void setup()
{
pinMode(3, OUTPUT);
}
void loop()
{
analogWrite(3, brightness); // pwm write on pin 3
++brightness; // brightness is incremented by 1
if (brightness <= 0 || brightness >= 255) {
brightness=0; // brightness limited to 0-255
"justify" class="MsoNormal">
}
delay(10);
}
delay(10);
}
Comments
Post a Comment