SlideShare a Scribd company logo
Arduino
Open Sourcing Imagination
myduino.com 1
Sypnopsis
 This workshop intends to expose participants to a much
simpler approach to microcontroller based on practical
problem-based approach.
 Enable participants to gain real-world experience to
monitor and control engineering processes and develop
competent skills.
 It has been specially designed for beginners and
educators
myduino.com 2
Microcontroller
 Microcontrollers are dedicated to
one task and run one specific
program.
 Examples of tasks could be:
i. Received from inputs via ports
(read from external hardware)
ii. Stored data in file registers &
arithmetic operations (added,
subtracted, logic gates)
iii. Sent out data (control external
hardware)
 Processor, Storage and RAM all in
one tiny package
myduino.com 3
myduino.com 4
With & Without A Microcontroller
Internal Architecture
Program
Memory Register
RAM EEPROM PORTS
Program Memory: Where all commands, written by users are stored
Register: To determine what action the uC takes in reference to the
program commands
RAM: Temporarily store data of any action
EEPROM: The data is retain even after power is switched-off
Ports: Bidirectional pins of Input and Output
myduino.com 5
myduino.com 6
Arduino Uno Specifications
 Microcontroller: ATmega328
 Operating Voltage: 5V
 Input Voltage (recommended): 7-12V
 Input Voltage (limits): 6-20V
 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
 Flash Memory: 32 KB (ATmega328) of which 0.5
KB used by bootloader
 SRAM: 2 KB (ATmega328)
 EEPROM: 1 KB (ATmega328)
 Clock Speed: 16 MHz
myduino.com 7
Arduino Terminology
 “sketch” – a program you write to run on an
Arduino board
 “pin” – an input or output connected to
something. e.g. output to an LED, input from
a knob.
 Analog signals – directly measurable
quantities in terms of some other quantity
 Digital Signals – have only two states. For
digital computers, we refer to binary states, 0
and 1. “1” can be on, “0” can be off
myduino.com 8
Workshop Summary
 Introduction to Arduino
 Setting up your Arduino Environment
 First Arduino sketch
 Making LEDs glow and blink
 How to read buttons/switches
 Analog Signals
 Serial Communication
 Digital Thermometer
myduino.com 9
Participant Manifest
 Thumb drive with notes, arduino software for
Windows and source code (“sketches”) used
in class
 Arduino Starter Kit:
Arduino Uno Tactile push button
Half size breadboard Liquid Crystal Display
Jumper wires Piezo Buzzer
LEDs USB Cable
Resistors Temperature Sensor
Potentiometer
myduino.com 10
Breadboard
 A breadboard (or protoboard)
is a construction base for
prototyping of electronics
 Wires and components are
simply pushed into the holes to
form a completed circuit and
power can be applied.
myduino.com 11
Components: LED
 LED (Light Emitting Diode)
 What it Does: Emits light
when a small current is passed
through it.
 Leads: 2 (one longer, this one
connects to positive)
 Things to watch out for: Will
only work in one direction
 Looks like a mini light bulb. -
Requires a current limiting
resistor
myduino.com 12
Resistors
 What it Does: Restricts
the amount of current
that can flow through a
circuit.
 Leads: 2
 Things to watch out
for: Easy to grab the
wrong value
 Cylinder with wires
extending from either
end. The value is
displayed using a color
myduino.com 13
Potentiometer
 What it Does: Produces a
variable resistance dependant
on the angular position of the
shaft.
 Leads: 3
 Things to watch out for:
 Identifying: - Accidentally
buying logarithmic scale.
 They can be packaged in
many different form factors,
look for a dial to identify.
myduino.com 14
Pushbutton
 What it Does: Completes a
circuit when it is pressed. 4
 Leads: 4
 A little square with leads out
the bottom and a button on the
top.
myduino.com 15
Piezo Element
 What it Does: A pulse of
current will cause it to click. A
stream of pulses will cause it
to emit a tone.
 Leads: 2
 Things to watch out for:
Difficult to misuse.
 In this kit it comes in a little
black barrel, but sometimes
they are just a gold disc
myduino.com 16
Temperature Sensor (LM35)
 The LM35 series are precision integrated-circuit
temperature sensors, whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature.
 The LM35 is rated to operate over a −55° to +150°C
temperature range, and has a linear + 10.0 mV/°C scale
factor.
myduino.com 17
Liquid Crystal Display
 An LCD has the advantage of
displaying alpha-numeric
characters and even user-
defined graphics.
 It also offers the ability for
lower power consumption,
making it ideal for battery
operated systems.
 It comes in a wide variety of
shapes and sizes with line
lengths of 8, 16, 20, 24, 32 and
40 characters, in one, two and
four line versions.
myduino.com 18
What is Electricity
 A fan contains a small battery,
a couple of wires, a switch and
an electric motor.
 If you turn the switch on, the
motor will start to spin
 Battery is both a water
reservoir and a pump, the
switch is a tap, and the motor
is one of those wheels that you
see in watermills.
 When you open the tap, water
flows from the pump and
pushes the wheel into motion.
myduino.com 19
The hydraulic system
 Increasing the size of the pipes
allows a greater flow of water
to go through them, effectively
reduced the pipes' resistance
to the flow of water.
 This approach works up to a
certain point, at which the
wheel won't spin any faster,
because the pressure of the
water is not strong enough.
 When we reach this point, we
need the pump to be stronger.
myduino.com 20
Voltage, Current & Resistance
 So when you read that a battery's voltage is 9 V, think of this voltage
like the water pressure that can potentially be produced by this little
"pump".
 The flow rate of water relates to current, and is measured in
amperes.
 Finally, the resistance opposing the flow of current over any path
that it travels is called resistance, and is measured in ohms.
 Relationship: A higher voltage (pressure) lets you spin a wheel
faster; a higher flow rate (current) lets you spin a larger wheel.
 Ohms Law, V = IR
myduino.com 21
myduino.com 22
myduino.com 23
myduino.com 24
 Breadboards have small holes for jumper wires and
components to be plugged into.
Construct Circuit 1
myduino.com 25
Construct Circuit 2
myduino.com 26
myduino.com 27
Select Board & Com Port
myduino.com 28
Blinking an LED
digitalWrite
 The Arduino board comes with
an LED preinstalled. It's
marked "L". You can also add
your own LED
 Tell Arduino what to do.
 This is done through code, that
is, a list of instructions that we
give the microcontroller to
make it do what we want.
 Blink an LED is the Hello
World of physical computing
myduino.com 29
myduino.com 30
myduino.com 31
Status Bar
myduino.com 32
myduino.com 33
Built-in Examples
myduino.com 34
myduino.com 35
Push Button – digitalRead
myduino.com 36
Pulse Width Modulation (PWM)
 If you blink the LED fast
enough, you don't see it blink
any more, but you can change
its brightness by changing the
ratio between the on time and
the off time.
 This technique also works with
devices other than an LED.
For example, you can change
the speed of a motor in the
same way
 analogWrite(9,128) will set the
brightness of an LED
connected to pin 9 to 50%.
myduino.com 38
myduino.com 39
Arduino PWM
8 Bits
Data Vout
x 0.0196
0
To
255
0
To
5V
PWM Output (Vout) = Data
5V 255
PWM Output (Vout) = Data x 5 V
255
= Data x 0.0196
Ex: If Data = 128; Vout = 128 x 0.0196 = 2.5088 V
analogWrite (PWM_pin, 128); // Will give an output of 2.5088 V
myduino.com 40
Analogue Input
 This is the difference
between an on/off
sensor (which tells us
whether something is
there) and an analogue
sensor, whose value
continuously changes.
 By using the
analogRead() function,
we can read the voltage
applied to one of the
pins. This function
returns a number
between 0 and 1023,
which represents
voltages between 0 and
5 volts
myduino.com 41
myduino.com 42
Number of iterations (steps) for an ADC is
calculated as follows:
2N
= Number of steps.
Where N corresponds to the number of bits
Ex: 2 bits, 22
= 4
Resolution = Voltage Range = 5V = 1.25
No of steps 4
Vin Dout
0 – 1.25 0
1.25 – 2.5 1
2.5 – 3.75 2
3.75 - 5 3
Arduino ADC Calculations
 10 bit ADC, 210
= 1024 steps
 The resolution of an ADC is calculated as follows:
Resolution = Voltage Range = 5V = 0.00488 V
No of steps 1024
 The output of the ADC is calculated as follows:
ADC Output (dout) = Vin = 3.3 = 676
Resolution 0.00488
myduino.com 43
ADC Output (dout) = Vin = 3.3 = 676
Resolution 0.00488
myduino.com 44
ADC Arduino
10 bits
vin dout
÷ 0.00488
x 0.00488
Vin = dout x Resolution = 676 x 0.00488 = 3.3
myduino.com 45
Producing Variable Voltage
Temperature Sensor (LM35)
 The LM35 series are precision integrated-circuit
temperature sensors, whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature.
 The LM35 is rated to operate over a −55° to +150°C
temperature range, and has a linear + 10.0 mV/°C scale
factor.
myduino.com 46
myduino.com 47
Liquid Crystal Display
 An LCD has the advantage of
displaying alpha-numeric
characters and even user-
defined graphics.
 It also offers the ability for
lower power consumption,
making it ideal for battery
operated systems.
 It comes in a wide variety of
shapes and sizes with line
lengths of 8, 16, 20, 24, 32 and
40 characters, in one, two and
four line versions.
myduino.com 48
myduino.com 49
myduino.com 50
Connecting your LCD (Backlight)
myduino.com 51
Connecting your Power & Contrast
myduino.com 52
Connecting your Bus Wiring
myduino.com 53
LCD 14 13 12 11 10 9 8 7 6 5 4 3 2 1
7 6 5 4 3 GND 2 POT 5V GND
myduino.com 54
Reconnecting your LM35
Arduino Library
 A library is a big collection of related procedures.
 If you, say, want to control a motor, you may want
to find a Motor Control Library: a collection of
procedures that have already been written for you
that you can use without having to do the dirty
work of learning the nuances of motors.
 One of the best features of the Arduino project is
the ability to add on pre-crafted libraries that add
hardware support. There's tons of them, and you
can pick and choose which to install.
Arduino Library
 A library is a folder with some files in it, the files will end
in .cpp (C++ code file) and .h (C++ header file).
 Two optional files are keywords.txt (this is a hints file to
tell the Arduino IDE how to colorize your sketch and
examples folder, which may have some handy test-
sketches.
How to Install Library
 Download your desired library
(normally in a compressed zip file)
 Find the zip file on your local computer
(wherever downloaded files end up).
Under Windows, you should be able to
double click on the file to open it up.
Older windows, winrar or winzip will
pop-up.
 Copy the file and paste in inside the
libraries folder in your Arduino
directory.
Arduino Shield
myduino.com 58
Arduino Tracker
59
GOOD SITES:
1. myduino.com
2. http://www.facebook.com/groups/arduinomalaysia/?
ref=ts&fref=ts
3. http://tronixstuff.wordpress.com/
4. http://bildr.org/
5. http://www.instructables.com
6. http://www.jeremyblum.com/category/arduino-tutorials/
7. http://letsmakerobots.com/start
8. http://hackaday.com
9. http://playground.arduino.cc/

More Related Content

PPTX
Introduction to arduino
PDF
Arduino projects-pdf-download-list-jan-2015
PDF
Contactless digital tachometer using microcontroller
PPTX
Arduino Slides With Neopixels
PDF
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
PPTX
04 Arduino Peripheral Interfacing
PDF
Arduino learning
PPTX
Getting started with arduino workshop
Introduction to arduino
Arduino projects-pdf-download-list-jan-2015
Contactless digital tachometer using microcontroller
Arduino Slides With Neopixels
Advanced view of atmega microcontroller projects list 1649 at mega32 avr
04 Arduino Peripheral Interfacing
Arduino learning
Getting started with arduino workshop

What's hot (20)

PPTX
Introduction to arduino!
PDF
DHT11 Digital Temperature and Humidity Sensor
PDF
Arduino Workshop Day 2 - Advance Arduino & DIY
PDF
Arduino Workshop Day 1 - Basic Arduino
PPTX
03 analogue anrduino fundamentals
PPSX
Arduino by yogesh t s'
PDF
Advanced view arduino projects list use arduino for projects (3)
PDF
Lab2ppt
PPTX
Introduction to Arduino & Robotics
PPTX
02 General Purpose Input - Output on the Arduino
DOC
Fading leds via pwm
PPTX
Arduino slides
PDF
Lecture6
PPT
Getting Started With Arduino How To Build A Twitter Monitoring Alertuino
PPTX
Porte à puce - Smart Safety Door based on Arduino UNO R3
PPTX
Monitoring temperature rumah dengan display lcd dan recording
PPTX
Porte à puce - Automatic Door based on Arduino UNO R3
PPT
ARDUINO AND ITS PIN CONFIGURATION
PPTX
Basic Sensors
Introduction to arduino!
DHT11 Digital Temperature and Humidity Sensor
Arduino Workshop Day 2 - Advance Arduino & DIY
Arduino Workshop Day 1 - Basic Arduino
03 analogue anrduino fundamentals
Arduino by yogesh t s'
Advanced view arduino projects list use arduino for projects (3)
Lab2ppt
Introduction to Arduino & Robotics
02 General Purpose Input - Output on the Arduino
Fading leds via pwm
Arduino slides
Lecture6
Getting Started With Arduino How To Build A Twitter Monitoring Alertuino
Porte à puce - Smart Safety Door based on Arduino UNO R3
Monitoring temperature rumah dengan display lcd dan recording
Porte à puce - Automatic Door based on Arduino UNO R3
ARDUINO AND ITS PIN CONFIGURATION
Basic Sensors
Ad

Similar to Notes arduino workshop_15 (20)

PPTX
Arduino Workshop (3).pptx
PPTX
Ardui no
PDF
arduinoworkshop-160204051621.pdf
PDF
ARDUINO PROJECTS BOOK
PDF
Arduino Comic-Jody Culkin-2011
PDF
Arduino comic v0004
PPTX
Arduino Introduction Guide 1
PPTX
Designers, please mind the gap! Let's get started with Arduino
PPTX
Arduino Workshop Slides
PDF
Arduino: Libros de proyectos para Arduino
PDF
Making things sense - Day 1 (May 2011)
PPTX
embedded_in_Arduino_with_basic_embedded.pptx
PPTX
Electronz_Introduction.pptx
DOCX
Arduino PAPER ABOUT INTRODUCTION
PPTX
Intro_to_Arduino_-_v30.pptx
PDF
Electronics_Tutorial_2022_Slide543404210s.pdf
PDF
02 Sensors and Actuators Understand .pdf
PPTX
Microcontroller Programming & Hardware Introduction
PPT
Intro_to_Arduino_with_coding_explained.ppt
PDF
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
Arduino Workshop (3).pptx
Ardui no
arduinoworkshop-160204051621.pdf
ARDUINO PROJECTS BOOK
Arduino Comic-Jody Culkin-2011
Arduino comic v0004
Arduino Introduction Guide 1
Designers, please mind the gap! Let's get started with Arduino
Arduino Workshop Slides
Arduino: Libros de proyectos para Arduino
Making things sense - Day 1 (May 2011)
embedded_in_Arduino_with_basic_embedded.pptx
Electronz_Introduction.pptx
Arduino PAPER ABOUT INTRODUCTION
Intro_to_Arduino_-_v30.pptx
Electronics_Tutorial_2022_Slide543404210s.pdf
02 Sensors and Actuators Understand .pdf
Microcontroller Programming & Hardware Introduction
Intro_to_Arduino_with_coding_explained.ppt
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
Ad

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PPTX
Lesson notes of climatology university.
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
RMMM.pdf make it easy to upload and study
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Cell Types and Its function , kingdom of life
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
master seminar digital applications in india
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
Classroom Observation Tools for Teachers
Lesson notes of climatology university.
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
VCE English Exam - Section C Student Revision Booklet
RMMM.pdf make it easy to upload and study
A systematic review of self-coping strategies used by university students to ...
GDM (1) (1).pptx small presentation for students
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
Cell Types and Its function , kingdom of life
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
2.FourierTransform-ShortQuestionswithAnswers.pdf
Final Presentation General Medicine 03-08-2024.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O5-L3 Freight Transport Ops (International) V1.pdf
master seminar digital applications in india
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Anesthesia in Laparoscopic Surgery in India

Notes arduino workshop_15

  • 2. Sypnopsis  This workshop intends to expose participants to a much simpler approach to microcontroller based on practical problem-based approach.  Enable participants to gain real-world experience to monitor and control engineering processes and develop competent skills.  It has been specially designed for beginners and educators myduino.com 2
  • 3. Microcontroller  Microcontrollers are dedicated to one task and run one specific program.  Examples of tasks could be: i. Received from inputs via ports (read from external hardware) ii. Stored data in file registers & arithmetic operations (added, subtracted, logic gates) iii. Sent out data (control external hardware)  Processor, Storage and RAM all in one tiny package myduino.com 3
  • 4. myduino.com 4 With & Without A Microcontroller
  • 5. Internal Architecture Program Memory Register RAM EEPROM PORTS Program Memory: Where all commands, written by users are stored Register: To determine what action the uC takes in reference to the program commands RAM: Temporarily store data of any action EEPROM: The data is retain even after power is switched-off Ports: Bidirectional pins of Input and Output myduino.com 5
  • 7. Arduino Uno Specifications  Microcontroller: ATmega328  Operating Voltage: 5V  Input Voltage (recommended): 7-12V  Input Voltage (limits): 6-20V  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  Flash Memory: 32 KB (ATmega328) of which 0.5 KB used by bootloader  SRAM: 2 KB (ATmega328)  EEPROM: 1 KB (ATmega328)  Clock Speed: 16 MHz myduino.com 7
  • 8. Arduino Terminology  “sketch” – a program you write to run on an Arduino board  “pin” – an input or output connected to something. e.g. output to an LED, input from a knob.  Analog signals – directly measurable quantities in terms of some other quantity  Digital Signals – have only two states. For digital computers, we refer to binary states, 0 and 1. “1” can be on, “0” can be off myduino.com 8
  • 9. Workshop Summary  Introduction to Arduino  Setting up your Arduino Environment  First Arduino sketch  Making LEDs glow and blink  How to read buttons/switches  Analog Signals  Serial Communication  Digital Thermometer myduino.com 9
  • 10. Participant Manifest  Thumb drive with notes, arduino software for Windows and source code (“sketches”) used in class  Arduino Starter Kit: Arduino Uno Tactile push button Half size breadboard Liquid Crystal Display Jumper wires Piezo Buzzer LEDs USB Cable Resistors Temperature Sensor Potentiometer myduino.com 10
  • 11. Breadboard  A breadboard (or protoboard) is a construction base for prototyping of electronics  Wires and components are simply pushed into the holes to form a completed circuit and power can be applied. myduino.com 11
  • 12. Components: LED  LED (Light Emitting Diode)  What it Does: Emits light when a small current is passed through it.  Leads: 2 (one longer, this one connects to positive)  Things to watch out for: Will only work in one direction  Looks like a mini light bulb. - Requires a current limiting resistor myduino.com 12
  • 13. Resistors  What it Does: Restricts the amount of current that can flow through a circuit.  Leads: 2  Things to watch out for: Easy to grab the wrong value  Cylinder with wires extending from either end. The value is displayed using a color myduino.com 13
  • 14. Potentiometer  What it Does: Produces a variable resistance dependant on the angular position of the shaft.  Leads: 3  Things to watch out for:  Identifying: - Accidentally buying logarithmic scale.  They can be packaged in many different form factors, look for a dial to identify. myduino.com 14
  • 15. Pushbutton  What it Does: Completes a circuit when it is pressed. 4  Leads: 4  A little square with leads out the bottom and a button on the top. myduino.com 15
  • 16. Piezo Element  What it Does: A pulse of current will cause it to click. A stream of pulses will cause it to emit a tone.  Leads: 2  Things to watch out for: Difficult to misuse.  In this kit it comes in a little black barrel, but sometimes they are just a gold disc myduino.com 16
  • 17. Temperature Sensor (LM35)  The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature.  The LM35 is rated to operate over a −55° to +150°C temperature range, and has a linear + 10.0 mV/°C scale factor. myduino.com 17
  • 18. Liquid Crystal Display  An LCD has the advantage of displaying alpha-numeric characters and even user- defined graphics.  It also offers the ability for lower power consumption, making it ideal for battery operated systems.  It comes in a wide variety of shapes and sizes with line lengths of 8, 16, 20, 24, 32 and 40 characters, in one, two and four line versions. myduino.com 18
  • 19. What is Electricity  A fan contains a small battery, a couple of wires, a switch and an electric motor.  If you turn the switch on, the motor will start to spin  Battery is both a water reservoir and a pump, the switch is a tap, and the motor is one of those wheels that you see in watermills.  When you open the tap, water flows from the pump and pushes the wheel into motion. myduino.com 19
  • 20. The hydraulic system  Increasing the size of the pipes allows a greater flow of water to go through them, effectively reduced the pipes' resistance to the flow of water.  This approach works up to a certain point, at which the wheel won't spin any faster, because the pressure of the water is not strong enough.  When we reach this point, we need the pump to be stronger. myduino.com 20
  • 21. Voltage, Current & Resistance  So when you read that a battery's voltage is 9 V, think of this voltage like the water pressure that can potentially be produced by this little "pump".  The flow rate of water relates to current, and is measured in amperes.  Finally, the resistance opposing the flow of current over any path that it travels is called resistance, and is measured in ohms.  Relationship: A higher voltage (pressure) lets you spin a wheel faster; a higher flow rate (current) lets you spin a larger wheel.  Ohms Law, V = IR myduino.com 21
  • 24. myduino.com 24  Breadboards have small holes for jumper wires and components to be plugged into.
  • 28. Select Board & Com Port myduino.com 28
  • 29. Blinking an LED digitalWrite  The Arduino board comes with an LED preinstalled. It's marked "L". You can also add your own LED  Tell Arduino what to do.  This is done through code, that is, a list of instructions that we give the microcontroller to make it do what we want.  Blink an LED is the Hello World of physical computing myduino.com 29
  • 35. myduino.com 35 Push Button – digitalRead
  • 37. Pulse Width Modulation (PWM)  If you blink the LED fast enough, you don't see it blink any more, but you can change its brightness by changing the ratio between the on time and the off time.  This technique also works with devices other than an LED. For example, you can change the speed of a motor in the same way  analogWrite(9,128) will set the brightness of an LED connected to pin 9 to 50%.
  • 39. myduino.com 39 Arduino PWM 8 Bits Data Vout x 0.0196 0 To 255 0 To 5V PWM Output (Vout) = Data 5V 255 PWM Output (Vout) = Data x 5 V 255 = Data x 0.0196 Ex: If Data = 128; Vout = 128 x 0.0196 = 2.5088 V analogWrite (PWM_pin, 128); // Will give an output of 2.5088 V
  • 41. Analogue Input  This is the difference between an on/off sensor (which tells us whether something is there) and an analogue sensor, whose value continuously changes.  By using the analogRead() function, we can read the voltage applied to one of the pins. This function returns a number between 0 and 1023, which represents voltages between 0 and 5 volts myduino.com 41
  • 42. myduino.com 42 Number of iterations (steps) for an ADC is calculated as follows: 2N = Number of steps. Where N corresponds to the number of bits Ex: 2 bits, 22 = 4 Resolution = Voltage Range = 5V = 1.25 No of steps 4 Vin Dout 0 – 1.25 0 1.25 – 2.5 1 2.5 – 3.75 2 3.75 - 5 3
  • 43. Arduino ADC Calculations  10 bit ADC, 210 = 1024 steps  The resolution of an ADC is calculated as follows: Resolution = Voltage Range = 5V = 0.00488 V No of steps 1024  The output of the ADC is calculated as follows: ADC Output (dout) = Vin = 3.3 = 676 Resolution 0.00488 myduino.com 43
  • 44. ADC Output (dout) = Vin = 3.3 = 676 Resolution 0.00488 myduino.com 44 ADC Arduino 10 bits vin dout ÷ 0.00488 x 0.00488 Vin = dout x Resolution = 676 x 0.00488 = 3.3
  • 46. Temperature Sensor (LM35)  The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature.  The LM35 is rated to operate over a −55° to +150°C temperature range, and has a linear + 10.0 mV/°C scale factor. myduino.com 46
  • 48. Liquid Crystal Display  An LCD has the advantage of displaying alpha-numeric characters and even user- defined graphics.  It also offers the ability for lower power consumption, making it ideal for battery operated systems.  It comes in a wide variety of shapes and sizes with line lengths of 8, 16, 20, 24, 32 and 40 characters, in one, two and four line versions. myduino.com 48
  • 51. Connecting your LCD (Backlight) myduino.com 51
  • 52. Connecting your Power & Contrast myduino.com 52
  • 53. Connecting your Bus Wiring myduino.com 53 LCD 14 13 12 11 10 9 8 7 6 5 4 3 2 1 7 6 5 4 3 GND 2 POT 5V GND
  • 55. Arduino Library  A library is a big collection of related procedures.  If you, say, want to control a motor, you may want to find a Motor Control Library: a collection of procedures that have already been written for you that you can use without having to do the dirty work of learning the nuances of motors.  One of the best features of the Arduino project is the ability to add on pre-crafted libraries that add hardware support. There's tons of them, and you can pick and choose which to install.
  • 56. Arduino Library  A library is a folder with some files in it, the files will end in .cpp (C++ code file) and .h (C++ header file).  Two optional files are keywords.txt (this is a hints file to tell the Arduino IDE how to colorize your sketch and examples folder, which may have some handy test- sketches.
  • 57. How to Install Library  Download your desired library (normally in a compressed zip file)  Find the zip file on your local computer (wherever downloaded files end up). Under Windows, you should be able to double click on the file to open it up. Older windows, winrar or winzip will pop-up.  Copy the file and paste in inside the libraries folder in your Arduino directory.
  • 60. GOOD SITES: 1. myduino.com 2. http://www.facebook.com/groups/arduinomalaysia/? ref=ts&fref=ts 3. http://tronixstuff.wordpress.com/ 4. http://bildr.org/ 5. http://www.instructables.com 6. http://www.jeremyblum.com/category/arduino-tutorials/ 7. http://letsmakerobots.com/start 8. http://hackaday.com 9. http://playground.arduino.cc/