You are on page 1of 15

4.1.

Microcontroller
Overview

Fig 4.11.1. Arduino Mega 2560 Microcontroller


The Arduino Mega 2560 is a microcontroller board based on the ATmega2560. 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.

Summary
Microcontroller
ATmega2560
Operating Voltage
5V
Input Voltage
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 boot loader
SRAM
8 KB
EEPROM
4 KB
Clock Speed
16 MHz
Table 4.11.1 Microcontroller Overview
Power

VIN. The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can supply
voltage through this pin, or, if supplying voltage via the power jack, access it through this pin.
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. GND. Ground pins.
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).
Input and Output
Each of the 54 digital pins on the Mega can be used as an input or output,
using pinMode(), digitalWrite(), anddigitalRead() functions. They operate at 5 volts. Each pin
can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected
by default) of 20-50 kOhms. In addition, some pins have specialized functions:
Analog Inputs :16 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.

Programming
The Arduino Mega can be programmed with the Arduino software.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.
You can also bypass the bootloader and program the microcontroller through the ICSP (InCircuit Serial Programming) header.

Products
Browse the wide range of official Arduino boards, shields, kits and accessories.
The newly introduced Galileo board from Intel is part of the Arduino Certified product line.
Take a look at the ArduinoAtHeart program and products, designed for makers and companies
wanting to make their products easily recognizable as based on the Arduino technology.
BOARDS (Compare Specs)

Arduino Uno

Arduino Leonardo

SHIELDS

Arduino GSM Shield

KITS

The Arduino
Starter Kit

Arduino Due

Arduino Yn

Arduino Ethernet
Shield

Arduino Materia
101

ACCESSORIES

Arduino Tre

Arduino Zero

Arduino WiFi Shield

Arduino Micro

Arduino Esplora

Arduino Wireless SD
Shield

TFT LCD screen

Arduino Mega
ADK

Arduino Ethernet

Arduino USB Host


Shield

USB/Serial Light
Adapter

Arduino Mega
2560

Arduino Robot

Arduino Motor
Shield

Arduino ISP

Arduino Mini

Arduino Nano

Arduino Wireless
Proto Shield

Mini USB/Serial
Adapter

LilyPad Arduino
Simple

LilyPad ArduinoSimp
leSnap

Arduino Proto Shield

LilyPad Arduino

LilyPad Arduino USB

Arduino Pro Mini

Arduino Fio

Arduino Pro

Program
The Arduino Certified program is designed for companies using processors not currently
supported by Arduino who want to certify a basic level of compatibility with the Arduino
platform..
Benefits

Receive advice and assistance from Arduino developers on creating documentation


compliant with OSHW practices.

Receive support in the packaging of a custom IDE.

Tap into the power of the Arduino community

Add the Arduino Certified logo on the product

A page on the Arduino website describing the products with pointers to relevant
documentation to the companys website

The product can be made available through the Arduino online Store if desired.
Requirements
Participation in the program requires that your company provides:

Independent design of the board and development of the software.

Download links to the customized IDE on your companys website.

Technical support to users on your companys website.

Payment of a licence fee to Arduino .

For more information about the "Arduino Certified" program please write to: certified [at]
arduino.cc

4.2. Arduino IDE


Arduino is an open-source electronics
prototyping platform based on flexible,
easy-to-use hardware and software. It's
intended for artists, designers, hobbyists,
and

anyone

interested

in

creating

interactive objects or environments.


Arduino can sense the environment by
receiving input from a variety of sensors
and can affect its surroundings by
controlling lights, motors, and other
actuators. The microcontroller on the
board is programmed using the Arduino
programming language (based on Wiring)
and

the

environment

Arduino
(based

development
on Processing).

Arduino projects can be stand-alone or


they can communicate with software
running on a computer
Fig 4.12 Arduino IDE
Arduino Development Environment

The Arduino development environment contains a text editor for writing code, a message area, a
text console, a toolbar with buttons for common functions, and a series of menus. It connects to
the Arduino hardware to upload programs and communicate with them.Software written using
Arduino are called sketches. These sketches are written in the text editor. Sketches are saved with
the file extension .ino. It has features for cutting/pasting and for searching/replacing text. The
message area gives feedback while saving and exporting and also displays errors. The console
displays text output by the Arduino environment including complete error messages and other
information. The bottom righthand corner of the window displays the current board and serial
port. The toolbar buttons allow you to verify and upload programs, create, open, and save
sketches, and open the serial monitor:
Verify
Checks your code for errors.
Upload
Compiles your code and uploads it to the Arduino I/O board.
See uploading below for details.
Note: If you are using an external programmer, you can hold down the
"shift" key on your computer when using this icon. The text will change to
"Upload using Programmer"
New
Creates a new sketch.
Open
Presents a menu of all the sketches in your sketchbook. Clicking one will
open it within the current window.
Note: due to a bug in Java, this menu doesn't scroll; if you need to open a
sketch late in the list, use the File | Sketchbook menu instead.
Save
Saves your sketch.
Serial
Opens the serial monitor.
Table 4.12 Arduino development environment content

Monitor

Additional commands are found within the five menus: File, Edit, Sketch, Tools, Help. The
menus are context sensitive which means only those items relevant to the work currently being
carried out are available.

Language Reference
Arduino programs can be divided in three main
parts: structure, values (variables and constants), andfunctions.

Structure
setup()

Functions

Variables

Digital I/O

Constants

loop()
Control
Structures

pinMode()

HIGH | LOW

digitalWrite()

INPUT | OUTPUT | I
NPUT_PULLUP

LED_BUILTIN

true | false

integer constants

digitalRead()
if
if...else

Analog I/O
analogReference()

for

analogRead()

switch
case

analogWrite() - PWM
while

while

analogReadResolution(
)

ue

void

boolean

char

Advanced I/O

unsigned char

break
contin

Data Types

Due only

do...

floating point
constants

analogWriteResolution(

return

tone()

byte

goto

noTone()

int

shiftOut()

unsigned int

shiftIn()

word

pulseIn()

long

unsigned long

millis()

short

micros()

float

Further
Syntax
; (semi
colon)
{} (cur
ly braces)
// (sing
le line

Time

comment)

delay()

double

/*
*/ (multi-line
comment)

delayMicroseconds()

string - char array

String - object

array

#defin
e
#inclu

Math
min()
max()

Conversion

de

abs()

char()

Arithmetic
Operators

constrain()

byte()

map()

int()

pow()

word()

sqrt()

long()

float()

= (assi
gnment
operator)
+ (ad
dition)
- (subtr
action)
* (mult
iplication)
/ (divisi
on)
% (mo
dulo)

Trigonometry
sin()

Variable Scope &


Qualifiers

cos()

variable scope

static

volatile

const

tan()
Random Numbers
randomSeed()
random()

Comparison
Operators
== (eq
ual to)
!= (not
equal to)
< (less

Utilities
Bits and Bytes
lowByte()
highByte()
bitRead()
bitWrite()

sizeof()

PROGMEM

than)

bitSet()

> (gre
ater than)

bitClear()

<= (le
ss than or
equal to)
>= (gr
eater than or
equal to)
Boolean
Operators
&& (an
d)
|| (or)
! (not)
Pointer
Access
Operators
*
dereference
operator
&
reference
operator
Bitwise
Operators
& (bitw
ise and)
| (bitwi
se or)

bit()
External Interrupts
attachInterrupt()
detachInterrupt()
Interrupts
interrupts()
noInterrupts()
Communication
Serial
Stream
USB (Leonardo and Due
only)
Keyboard
Mouse

^ (bitw
ise xor)
~ (bitw
ise not)
<< (bit
shift left)
>> (bit
shift right)
Compound
Operators
++ (in
crement)
-- (decr
ement)
+= (co
mpound
addition)
-= (co
mpound
subtraction)
*= (co
mpound
multiplicatio
n)
/= (co
mpound
division)
&= (co
mpound
bitwise and)
|= (co
mpound

bitwise or)

You might also like