Introduction to Arduino
Boards
Overview
Introduction to Microcontroller
Arduino boards
Quark – SOC processor
Programming
Arduino boards using GPIO
System design application
Case study
Architecture of advanced processors
Microcontrollers
Programmers work in the virtual world.
Machinery works in the physical world.
How does one connect the virtual world to the
physical world?
By microcontroller
A microcontroller is basically a small-scale
computer with generalized (and programmable)
inputs and outputs
They are dedicated to one task and run one
specific program
Microcontrollers are compact integrated circuit
designed to govern a specific operation in an
embedded system
A typical microcontroller includes a processor,
memory, and I/O peripherals on a single chip
while a microprocessor only contains the CPU.
Microcontrollers and Microprocessors are NOT
the same,
Microprocessors are used to execute big and generic
applications
Microcontrollers are used to execute a single task
within one application
Architecture
Microcontrollers architecture is based on two
types
Harvard architecture
Neumann architecture
It varies based on the different methods of
exchanging data between the processor and
memory.
Harvard - data bus and instruction bus are
separate, allowing for simultaneous transfers
Neumann - one bus is used for both data and
instructions.
Microcontroller
Advantages and Uses
Less expensive
All required components are within it
Uses less power
Computation capacity is low and uses low power
Highly sophisticated for embedded systems
Easily programmable
Used in all embedded system
More sophisticated microcontrollers perform
critical functions in aircraft, spacecraft, ocean-
going vessels, vehicles, medical and life-support
systems, and robots
Arduino – Official Definition
Arduino is an open-source electronics
prototyping platform based on flexible, easy-to-
use hardware and software.
It is intended for artists, designers, hobbyists,
and anyone interested in creating interactive
objects or environments.
Why Arduino?
For whatever reason, Arduino microcontrollers
have become the de facto standard.
Strives for the balance between ease of use and
usefulness.
Programming languages seen as major obstacle.
Arduino C is a greatly simplified version of C++.
Fast prototyping
Large community
Inexpensive.
Arduino Types
Many different versions
Number of input/output channels
Form factor
Processor
Uno
Leonardo
Due
Micro
LilyPad
Esplora
Arduino Uno Close Up
The pins are in three groups:
Invented in 2010
14 digital pins
6 analog pins
power
LilyPad
LilyPad is popular for clothing-based projects.
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.
Where to Start
Get an Arduino (starter kit)
Download the compiler
Connect the controller
Configure the compiler
Connect the circuit
Write the program
Get frustrated/Debug/Get it to work
Get excited and immediately start next project
(sleep is for wimps)
Arduino Starter Kits
Start with a combo pack (starter kit)
Includes a microcontroller, wire, LEDs, sensors, etc.
www.adafruit.com
adafruit.com/products/68 ($65)
www.sparkfun.com
https://www.sparkfun.com/products/11576 ($99.95)
Radio Shack
Make Ultimate Microcontroller Pack w/ Arduino Kit ($119.99)
www.makershed.com
http://www.makershed.com/Ultimate_Arduino_Microcontroller_Pack_p/msump1.
htm ($150)
What to Get – My Recommendation
Required: Good Idea:
Arduino (such as Uno) Capacitors
USB A-B (printer) cable Transistors
Breadboard DC motor/servo
Hookup wire Relay
LEDs
Advanced:
Resistors
Soldering iron & solder
Sensors
Heat shrink tubing
Switches
9V battery adapter
Bench power supply
Arduino Compiler
Download current compiler from:
arduino.cc/en/Main/software
Arrogantly refers to itself as an IDE (Ha!).
Run the software installer.
Written in Java, it is fairly slow.
Visit playground.arduino.cc/Main/
DevelopmentTools for alternatives to the
base arduino IDE
Configuring the Arduino Compiler
Defaults to COM1, will probably need to change
the COM port setting.
Appears in Device Manager (Win7) under Ports
as a Comm port.
Arduino Program Development
Based on C++ without 80% of the instructions.
A handful of new commands.
Programs are called 'sketches'.
Sketches need two functions:
void setup( )
void loop( )
setup( ) runs first and once.
loop( ) runs over and over, until power is lost or
a new sketch is loaded.
Arduino C
Arduino sketches are centered around the pins
on an Arduino board.
Arduino sketches always loop.
void loop( ) {} is equivalent to while(1) { }
The pins can be thought of as global variables.
Arduino C Specific Functions
pinMode(pin, mode)
Designates the specified pin for input or output
digitalWrite(pin, value)
Sends a voltage level to the designated pin
digitalRead(pin)
Reads the current voltage level from the designated pin
analog versions of above
analogRead's range is 0 to 1023
serial commands
print, println, write
Arduino C is Derived from C++
These programs blink an LED on pin 13
avr-libc Arduino C
#include <avr/io.h> void setup( ) {
#include <util/delay.h> pinMode(13, OUTPUT);
}
int main(void) {
while (1) { void loop( ) {
PORTB = 0x20; digitalWrite(13, HIGH);
_delay_ms(1000); delay(1000);
PORTB = 0x00; digitalWrite(13, LOW);
_delay_ms(1000); delay(1000);
} }
return 1;
}
Basic Electric Circuit
Every circuit (electric or electronic) must have at
least a power source and a load.
The simplest circuit is a light.
Plug in the light, and it lights up.
Unplug it, the light goes out.
Electricity flows from the power source,
through the load (the light) and then back to the
power source.
Basic LED Circuit
Connect the positive (+) lead of a power
source to the long leg of an LED.
Connect other leg of the LED to a resistor.
High resistance means a darker light.
Low resistance means brighter light.
No resistance means a burned out LED.
Connect other leg of the resistor to the
negative lead of the power source.
Blink Sketch
void setup( ) {
Connected to Connected to
pinMode(13, OUTPUT); one end of the
circuit
other end of the
circuit
}
void loop( ) {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
4 LED Blink Sketch
void setup( ) { void loop( ) {
pinMode(1, OUTPUT); digitalWrite(1, HIGH);
pinMode(3, OUTPUT); delay (200);
pinMode(5, OUTPUT); digitalWrite(1, LOW);
pinMode(7, OUTPUT);
} digitalWrite(3, HIGH);
delay (200);
digitalWrite(3, LOW);
digitalWrite(5, HIGH);
delay (200);
digitalWrite(5, LOW);
digitalWrite(7, HIGH);
delay (200);
digitalWrite(7, LOW);
}
So What?
Great. Blinking lights. Not impressed.
Only covered output thus far.
Can use analog inputs to detect a physical
phenomena.
Inputs
Digital inputs will come to the Arduino as either
on or off (HIGH or LOW, respectively).
HIGH is 5V DC.
LOW is 0V DC.
Analog inputs will come to the Arduino as a
range of numbers, based upon the electrical
characteristics of the circuit.
0 to 1023
.0049 V per digit (4.9 mV)
Read time is 100 microseconds (10,000 a second)
Analog Input
A potentiometer (variable
resistor) is connected to
analog pin 0 to an Arduino.
Values presented to pin 0 will
vary depending upon the
resistance of the
potentiometer.
Analog Input-Application
The variable resistor can be replaced with a
sensor.
For example, a photo resistor.
Depending upon the light level at the photo resistor:
Turn on a light
Increase or decrease the brightness of an LED (or an
LED array)
Most sensors are simply variable resistors, but
vary their resistance based on some physical
characteristic.
Sensors
Sensors can be both binary or a range.
Usually, sensors that measure a range of values
vary their resistance to reflect their detection.
Arduinos can only sense voltages, not
resistances.
Sensors that only vary their resistances require a
circuit called a voltage divider to provide the
Arduino, a voltage.
Common Sensors
Dials on a radio are Infrared sensor & light
simply potentiometers Hall effect sensor and
Temperature magnet
Light Ball tilt sensor (for
Angle measuring orientation)
Switches Force
did the user throw a
switch or push a button?
Accelerometer (measures
motion and tilt)
Shields
Shields are circuit boards that plug into the top
of an Arduino.
They extend the capabilities of an Arduino.
Examples:
Ethernet
GPS
Motor
Prototype
shieldlist.org
Case study :Arduinno based Home
Automation System
System design application