Professional Documents
Culture Documents
2 Architecture of Arduino and Application
2 Architecture of Arduino and Application
Architecture of Arduino
development board
http://www.arduino.cc/ 1
What do you need to start working
with Arduino?
1. Arduino board
2. USB cable
to be downloaded from
(http://arduino.cc/en/Main/Software)
2
What is Arduino?
5
Arduino Terminology
.
Esplora
Game controller
Includes joystick, four buttons, linear
potentiometer (slider), microphone, light sensor,
temperature sensor, three-axis accelerometer.
Not the standard set of IO pins.
Uno( means one )
The pins are in three groups:
6 analog inputs.
GPS Shield
Power Driver Shield
15
More Shields…
Communication shields - XBee, Ethernet, and Wifi
XBee Shield
GPS Module
Bluetooth Module
Flex Sensor
18
Sensors
Photoresistor, infared, force sensitive resistor, Hall
effect (varies its output voltage in response to a magnetic
field), Piezo, tilt sensor..
19
Arduino Uno Board Overview
20
Arduino Uno/ATmega328
Microcontroller ATmega328
Operating Voltage 5V
Input Voltage
7-12 V
(recommended)
Input Voltage (limits) 6-20 V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
32 KB (ATmega328) of which 2 KB used by
Flash Memory
bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz
21
Arduino Mega Board Overview
22
Arduino Mega/ATmega2560
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 (4 UARTs (hardware serial ports))
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
23
Nano
24
Nano
25
Arduino Board Schematic
26
Components of the Arduino
• ATMega168/328.
• 16MHz crystal/filtering
capacitors.
• Onboard power
regulators.
• FTDI USB <-> Serial
Chip.
• Hardware (Board).
27
Necessary parts for any circuit
• ATMega168/328.
• The ‘brains’ of the
Arduino.
• Program is loaded
onto the chip.
• Runs main loop until
power is removed.
28
Timing
• 16Mhz Crystal.
• The ‘heartbeat’ of the
ATMega chip.
• Speed of crystal
determines chip speed.
• ATMega series has
onboard oscillator.
29
Power Supply
30
FTDI USB Chip
31
Hardware
• Circuit Board
• Headers
• USB port
• Sockets
32
Digital or Analog?
• Digital – may take two values only: ON or OFF (1 or 0)
• Analog – has many (infinite) values
33
IO Pins
Arduino Digital I/0
pinMode(pin_no., dir)
digitalRead(pin)
digitalWrite(pin, value)
analogWrite(pin, value)
pin: the pin to write to.
value:PWM the duty cycle: between 0
(always off) and 255.
int x = analogRead(A0);
Pin Used as an Output
pinMode(0,OUTPUT);
Turn on the LED
digitalWrite(0,HIGH) ;
Turn off the LED
digitalWrite(0,LOW);
Pins as Inputs and Pull-up Resistors - 1
Using a switch as a sensor
Ex. Seat belt sensor ATmega328
Detect the switch state
What should the data direction be for Arduino
pin 3
Arduino pin 3 (PD3)? (PD3)
pinMode(3, INPUT);
What will the voltage be on PD3
when the switch is closed?, 0v.
What will the voltage be on PD3
when the switch is open?????
Pins as Inputs and Pull-up Resistors - 2
pinMode(3,INPUT_PULLUP);
What will the voltage on PD3 be
when the switch is open?, =5v
What will the voltage on PD3 be
when the switch is closed?, =0v
Pins as Inputs and Pull-up Resistors - 3
ATmega328
Switch as a sensor, cont. VTG= +5V
To turn off the pull-up
resistor, assuming PD3 1
PD3
is an input: 0
pinMode(3,INPUT)
Pins as Inputs and Pull-up Resistors - 4
ATmega328
VTG= +5V
iweak
Possibility of ‘weak drive’
1
PD3
0
Pin Voltages
• 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. (7v-12v)
• 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 FTDI chip. Maximum current
draw is 50 mA.
Power connector
44
Serial data transfer with Arduino
UNO
1. Universal asynchronous receiver/transmitter (UART)
2. Serial Peripheral Interface (SPI)
3. Inter-integrated Circuit (I2C) or Two-Wire Interface (TWI)
(UART)