SlideShare a Scribd company logo
Getting Started
with the
Arduino Uno
by Eric J. Richardson and Vui Nguyen
September 2017
Legal Disclaimer
Arduino is a trademark of somebody, certainly
But not us
Why this Presentation?
● Last year, we started
doing IoT when we
entered the Intel IoT
Roadshow
●“Save the Water Pipes”
was an automated
faucet dripper – handy to
prevent pipes from
freezing and breaking in
cold climates like
Colorado!
● Vui: software architect
● Eric: hardware engineer
● Crystal: web developer
Why this Presentation?
●We entered our project in
the US-China Young Maker
Competition (Sponsored by
Intel) and competed in
China!
● Vui presented our “Save
the Water Pipes” project to
Women Who Code
● Several of the Women Who Code had questions
about the Intel Edison board which powered our
project
Why this Presentation?
● There was a lot of interest in the Intel Edison
● The Edison is cool, but at $100 it’s a bit pricey
to get started with an embedded computing
project
● so Eric did a follow up presentation at WWC on
the Raspberry Pi
● Why the Raspberry Pi?
Why this Presentation?
● Raspberry Pi is a great value, single-board computer, and can
be used as the basis for many projects
● At Raspberry Pi presentation, Eric also provided a good
overview of electronics and hardware concepts
● But there is a lot of setup with Raspberry Pi just to get started
● With Arduino Uno, you could get up and running much more
quickly, for as much money, with less equipment and setup
Who is this Presentation For?
● This presentation is for software devs interested in
learning about hardware
● You should, by the end, know enough to get an Arduino
Uno up and running, and writing Arduino sketches
● And, hopefully, driving electronic circuits
● We hope that we cover at least one thing you already
know, and at least one thing you don't
● If you have a question about something, please ask! We
may wave it off as something we cover later
Personal Disclaimer
For those of you who are already familiar with all of this, Eric
apologizes if he sounds like he's “mansplaining”! He now has
Vui co-presenting to help with this.
Who Are We?
Eric J. Richardson
Lockheed Martin Systems Engineer
Colorado State University
B.S. Electrical & Computer Engineering, 2004
LIKES: DISLIKES:
● Antique Cars
● Dogs
● Shadowrun
● Cajun Food
● Old Video Games
● Hand Tools
● Cool Boots
● Cancer
● Fascism
● Lasagna
● TV Commercials
Which Assume I'm
Familiar with
Sports Stars
Who Are We?
Vui Nguyen
SimplyE iOS Developer
Colorado School of Mines
B.S. Computer Science, 1999
University of Denver
M.S. Computer Science, 2006
LIKES: DISLIKES:
● Fishing
● Eating
● Fishing
● Traveling
● Fishing
● Dogs
● Fishing
● Not Fishing
Enough
● Sexism
● Doing Dishes
● Negativity
● Being asked,
“Where are you
from?”
Who Are We Not?
● We are not graphic artists!
● We are not full-fledged Arduino experts!
● We fully expect someone here to ask us a question we
don't know the answer to
What is “Arduino”?
● 3 things:
– Arduino is an Italian company that designs low-cost
computers designed to interact with physical hardware
● These are open-source hardware designs
– “Arduino-compatible” boards have special I/O ports that
allow the boards to be expanded with plugin-in modules
called shields
– It’s also the Arduino-specific programming language
(based on C++) and IDE
● We will be working with the Arduino Uno board
Arduino Uno: What Does It Have?
Arduino Uno
● 14 Digital Input / Output pins (6 of these can be used as Analog outputs)
● 6 Analog inputs
● Atmel 8-bit microcontroller
● USB or plug-in power
● Arduino-compatible I/O; can plug in additional “shields”
● Ability to run Arduino sketches without any additional software installation
● Low-low price of ~$25
Arduino Uno: What Does It NOT Have?
The Arduino Uno does not have one of everything. Some things
you can add, and some things you have to live without:
● Networking capability
● Multi-computing
● Native graphics or sound
capability
● Case
● Huge Processing Power
● Full-blown O/S
Arduino Uno: Required Equipment
● Arduino Uno ($25)
● USB A/B (male / male) cable
● 9V or 12V, center-pin-positive,
500mA (or more) power
supply (optional)
Electronics Mini-Lesson #1: Voltage, Current,
Power, and Charge
Direct-Current electricity has 4 dimensions:
● Voltage: How Hard The Electricity is Pushing
– measured in Volts, or V (also mV)
● Current: How Much Electricity is Flowing Right Now
– measured in Amperes, or Amps, or A (also mA)
● Power: How Much Work Electricity is Doing Right Now
– measured in Watts, or W (also mW, kW, MW, etc.)
● Charge: How Much Electricity There Is
– measured in Coulombs, or more usefully, Amp-Hours
(also mAh)
Electronics Mini-Lesson #1: Voltage, Current,
Power, and Charge
● What we call a power supply is a constant-voltage
source
– That is, a power supply will deliver its rated output
voltage up to its rated current output
– So, a 19.5V power supply, rated for 6.7A of output, can
deliver up to and including 6.7A without ill effect
Electronics Mini-Lesson #1: Voltage, Current,
Power, and Charge
● Power supplies can also deliver less than their rated
current output!
– They only deliver the current that the circuit “needs”
(more on this later)
– But, they always deliver the voltage that they are rated
for (unless they are overloaded)
● So, you can use a power supply rated for more current
than you need
● BUT, DO NOT use a power supply rated for more Voltage
than you need!
Electronics Mini-Lesson #1: Voltage, Current,
Power, and Charge
Electrical Power is always calculated by this formula:
Power = Voltage x Current
Or, if you prefer:
Watts = Volts x Amps
So, if you know the voltage and the current, you know the
power being delivered. Back to our earlier example, the
6.7A @ 19.5V power supply is capable of delivering:
19.5V x 6.7A = 130W
Electronics Mini-Lesson #1: Voltage, Current,
Power, and Charge
● Batteries, as far as circuits are concerned, work the same
as power supplies
– A battery will deliver its rated voltage up to its rated
current, though battery manufacturers do not always
tell you the rated current
● The biggest difference is that you also have to worry about
the charge of a battery, which you do not have to worry
about with a power supply
– A battery with a greater charge capacity (in amp-
hours, or Ah) will “last” longer between chargings
Arduino Uno: Optional Equipment
● breadboard ($5, but get 2, or 1 big one)
● Single Pole/Single Throw
Normally Open Switch ($2)
● 1kΩ resistors ($1)
Arduino Uno: Optional Equipment
● LED Assortment ($6)
● Male-to-Male Jumpers ($8)
● 1MΩ Potentiometers ($3)
Install Arduino IDE
● Download and install Arduino IDE for your OS
– https://www.arduino.cc/en/Guide/HomePage
● Follow instructions to “Install the board drivers”:
– https://www.arduino.cc/en/Guide/ArduinoUno
– And, from the same page, “Select your board type and
port”
● Sample code to get started:
– https://www.arduino.cc/en/Tutorial/BuiltInExamples
Hardware Building Blocks
● We will going to focus the rest of this presentation on using
the Arduino Uno as the basis of a hardware project
● This will take the form of the “Four Building Blocks” of
physical computing:
– Digital Output
– Digital Input
– Analog Output
– Analog Input
Hardware 100 – Blink an LED
● Before that, let's make sure the darn thing turn on
● Making sure you can get an LED to blink should always be
the first thing you do with any new hardware project
– It's the “Hello World” of hardware
blinkOneLED
● Wire the green LED up like this:
I/O 3
1kΩ
blinkOneLED
● Physically, it will look something like this:
Demonstration: blinkOneLED
● Let's make sure everything works!
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
First, some terminology.
This is a circuit diagram:
+
_Vin
Voltage Source
Load
(resistor)
+
_
Current
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
● Current flows out of the positive (+) terminal of the Voltage
Source, through the circuit, and into the (-) terminal of the
Voltage Source
● The amount of current that flows is given by Ohm's Law:
● Where E is Voltage, I is current, and R is the Resistance of
the load, in Ohms (Ω)
● Current I can also be express as:
E = I x R
I =
E
R
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
● So, for example, if Vin were 3.3V, and the load was 1kΩ,
the current in this circuit would be 3.3V / 1000Ω = 3.3 mA
● What if we were to take the load out of the circuit?
+
_Vin
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
● In this case, current cannot flow, because there is no
electrical path from the positive terminal of the voltage
source to the negative one.
● This is called an open circuit.
● Think of it as an infinite-resistance load.
– So, 3.3V / ∞Ω = 0A
● But what happens if we replace the load resistor with a
wire?
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
+
_Vin
Current?
● Wires have a resistance of 0Ω
● So, the current through the system is: 3.3V / 0Ω
● That would be infinite current, if the voltage source could
supply infinite current!
Electronics Mini-Lesson #2: Circuits, Open
Circuits, and Short Circuits
● Instead, the voltage source will attempt to supply as much
current as it can – enough to trip a circuit breaker, or more
likely, burn up a wire, or the voltage source itself
● This is called a short circuit
● Do not wire up a short circuit! That's how you burn up
components, and destroy circuit boards
Electronics Mini-Lesson #3: GND and Vin
Second, some shorthand.
This takes time to draw:
+
_Vin
Electronics Mini-Lesson #3: GND and Vin
● So, we will use two convenient shorthands.
● The positive terminal of the voltage source, and anything
connected to it, we call Vin, or we just name it whatever
the input voltage is (such as 3.3V)
● We denote it with this symbol:
● The negative terminal of the voltage source, and anything
connected to it, we call GND (“ground”).
● We denote GND with this symbol:
Vin
Electronics Mini-Lesson #3: GND and Vin
So:
+
_Vin
Vin
==
Electronics Mini-Lesson #4: Breadboards
● Breadboards are useful for wiring up circuit prototypes
without soldering
● There are different types, but they mostly look something
like this:
● The magic of a breadboard is that you can plug one wire
into one hole, and have it be electrically connected to
another wire plugged into another hole
Electronics Mini-Lesson #4: Breadboards
● The electrical connections are arranged like so:
● It is helpful to plug Vin into the + rail, and GND into the – rail
● On either side of the channel are 5 pins all connected to
each other
Electronics Mini-Lesson #4: Breadboards
● Breadboards cannot carry infinite current without burning
up!
– If your circuit needs to carry more than about 500mA, I
recommend not using a breadboard and jumpers: get
some thicker-gauge, dedicated wires
● Breadboards cannot handle infinite voltage without arcing
internally!
– If your circuit needs to deliver more than about 24V, I
recommend not using a breadboard and jumpers: get
some wires with thicker insulation
● These numbers give a wide safety margin
Electronics Mini-Lesson #5: LEDs
● “LED” stands for “Light Emitting Diode”
● They do not behave like resistors! We can model them
like this:
+
_VD
RD
Electronics Mini-Lesson #5: LEDs
● VD
is around 1.8V, while RD
is not very much – on the order
of 2Ω or so
● So, if you were to attach a 3.3V voltage source directly to
the LED, you would get:
● This might not sound like much, but the output pins of the
Arduino Uno can only output about 40mA or so apiece– if
you were to “ask” them for 750mA, it could shut down or
even damage the Arduino Uno
(3.3V – 1.8V) / 2Ω = 750mA
Electronics Mini-Lesson #5: LEDs
● This is why each LED needs a 1kΩ resistor in series with
it: Vin
1kΩ
● If the LED is too dim, try a 470Ω resistor
● If the LED is too bright, try a 2kΩ resistor
Electronics Mini-Lesson #5: LEDs
● Finally, LEDs are diodes, and the magic of a diode is that
they only allow current to flow in one direction
● The flat part of the diode bulb, or the shorter of the two
legs, should be oriented towards GND
● See http://media.bemyapp.com/control-led-lights/
digitalOutputs.py
● Wire the green, yellow, and red LED up like this:
I/O 3
1kΩ
I/O 5
1kΩ
I/O 6
1kΩ
digitalOutputs
● Physically, it will look something like this:
Demonstration: digitalOutputs
● Prepare to have your mind BLOWN!
● What it does: lights up a series of LEDs, one at a time, in
round robin fashion
● The Magic:
– Set LED pin mode to OUTPUT: we’re sending signals out
to the LEDs, not receiving from them
– Set digital write to HIGH to turn LED on
– Set digital write to LOW to turn LED off
– State is whether LED is currently on or off
– Check state of current LED in loop to determine which
LEDs need to be turned off/on
digitalInput
● Leaving the LEDs in place, wire the switch like this:
I/O 12
This is a single-throw switch. It
only has one position in which
the circuit is completed. For a
“normally open” switch, the
connection to GND will be
made when you close the
switch (press the button)
digitalInput
● Physically, it will look something like this:
Electronics Mini-Lesson #6: Pull-Ups / Pull-
Downs
When the switch is closed, the circuit will look like this:
Now, the I/O pin is connected to
GND, which the Arduino Uno will
read as “LOW.”
I/O 12
Electronics Mini-Lesson #6: Pull-Ups / Pull-
Downs
What is I/O 12 connected to when the switch is open?
● It's not connected to LOW anymore, but
it's also not connected to HIGH
● A digital input only has two options, so
the Arduino Uno must read it as LOW or
HIGH, but you don't know which one it
will “pick”
● This is called a “floating input,” and it is
bad, because you never know what
you're going to get!
I/O 12
Electronics Mini-Lesson #6: Pull-Ups / Pull-
Downs
● We can avoid floating inputs with “pull-up” and “pull-down”
resistors
● A pull-up will leave the input pin to read HIGH in the
absence of any other connection, while a pull-down will
leave a floating input to read LOW
● The Arduino Uno can implement pull-ups (but NOT pull-
downs) in code, as you will see
● Double-throw switches may not actually need pull-ups or
pull-downs, but it won't hurt anything if you implement
them anyway
I/O 12
Vin
Demonstration: digitalInput
● Pretty much the same as digitalOutputs, until you press the button
● What it does: Light up a series of LEDs, one at a time, in round robin
robin. Press a button to make the LEDs light up in the opposite
direction and at a faster speed.
● The Magic:
– Same concepts as digitalOutputs, but this time uses an array of LED
pins
– For each LED pin in array, turns LED on, pauses, turns LED off
– If button is not pressed, continue moving “forward” in turning LEDs
on / off
– If button is pressed, move backwards to turn LEDs on /off
analogOutputs
● Wire the green, yellow, and red LED up like this:
(same as digitalOutputs)
I/O 3
1kΩ
I/O 5
1kΩ
I/O 6
1kΩ
Arduino Uno I/O
By the way, why did we pick pins 3, 5, and 6,
of all the pins that we could have picked?
Because those pins are 3 of the Input / Output pins that
can also act as analog outputs (PWMs)
These pins are denoted by the ~ symbol
Electronics Mini-Lesson #7: Pulse Width
Modulation
● Because of the nature of field-effect transistors, digital
outputs – either HIGH or LOW – are easy for a computer
to generate
● Analog outputs, which may have a value between HIGH
and LOW – say, 1.7V, or 2.2V, or 3.1V – are NOT easy to
generate
● However, since we mostly only need analog outputs for
physical devices, which cannot instantly turn on and off,
we can simulate an analog input by rapidly turning a digital
signal off and on, and varying the percentage of time the
signal is “on”
Electronics Mini-Lesson #7: Pulse Width
Modulation
0V
3.3V
0
m
s
1
m
s
2
m
s
3
m
s
4
m
s
5
m
s
A 1kHz waveform, “off” for 50% of the time, and “on”
for 50% of the time.
The “duty cyle” is 50%.
The output voltage is effectively half of the maximum,
or 1.65V
Electronics Mini-Lesson #7: Pulse Width
Modulation
0V
3.3V
0
m
s
1
m
s
2
m
s
3
m
s
4
m
s
5
m
s
This 1kHz waveform is “off” for 75% of the time, and
“on” for 25% of the time.
The “duty cyle” is 25%.
The output voltage is effectively one-quarter of the
maximum, or .825V
Electronics Mini-Lesson #7: Pulse Width
Modulation
0V
3.3V
0
m
s
1
m
s
2
m
s
3
m
s
4
m
s
5
m
s
This 1kHz waveform is “off” for 25% of the time, and
“on” for 75% of the time.
The “duty cyle” is 75%.
The output voltage is effectively three-quarters of the
maximum, or 2.48V
Electronics Mini-Lesson #7: Pulse Width
Modulation
● This seems stupid, but it actually works very well for a
variety of applications
– Your car's fuel injectors
– Throttling the electric motors in a quadcopter
– Anti-lock brakes
● A PWM signal has two properties: the frequency and the
duty cycle
– The frequency should be fast enough that whatever
you're driving operates smoothly, and slow enough to
avoid high-frequency impedence
Electronics Mini-Lesson #7: Pulse Width
Modulation
● The PWM pins on the Arduino Uno are either 980 Hz (pins
5 and 6), or 490 Hz (pins 3, 9, 10, and 11)
– Both of these frequencies are much too fast for the eye
to notice an LED flickering
● The duty cycle can be anywhere between 0 (0%) and 255
(100%)
– If you want a percentage duty cycle, you must multiply
by 255 and divide by 100 to set the PWM
Demonstration: analogOutputs
● Behold the wonders of Pulse Width Modulation!
● What It Does: Lights up a group of LEDs all at once, at
different intervals/steps, from dimmest to brightest and
back to dim again
● The Magic:
– Instead of just turning on the LEDs all the way on or all
the way off, analog output lets us light up the LED
within a range of dimmer settings
– The settings are in large intervals/steps
Demonstration: analogOutputPulse
● This program shows what's possible with small changes in
PWM duty cycle
● What It Does: Gradually lights up a group of LEDs all at
once, from dimmest to brightest and back to dim again
● The Magic:
● Much like analogOutputs, except with PWM, the dimmer
settings can be much smaller intervals / steps
● Changes in the dim settings can be much more gradual
analogInput
● Finally, we have analog inputs
● Many times you wish to know not merely whether
something is happening, but how much it is happening
● Many sensors – temperature sensors, light sensors,
pressure sensors, etc. – will deliver an output voltage as a
reaction to whatever they're sensing
● We will model this voltage with a potentiometer (variable
resistor)
analogInput
● Wire the green, yellow, and red LED up like this:
(same as digitalOutputs)
I/O 3
1kΩ
I/O 5
1kΩ
I/O 6
1kΩ
analogInput
● And, wire the potentiometer up like this:
+5V
10MΩ A0
The end terminals can be wired
up in any direction, but the center
terminal should point to the analog
input pin
analogInput
● Physically, it will look something like this:
Demonstration: analogInput
● This program converts an analog input into an LED
readout of sorts
Demonstration: analogInput
● This effect would require a somewhat complicated circuit
to implement if we weren't using the microcontroller
● What It Does: Gradually light up each LED, one at a time,
as we turn up the knob on the potentiometer, and then
gradually dim each LED, one at a time, as we turn down
the knob on the potentiometer.
● The Magic:
– Cycling through an array of LEDs, based on the value
of the potentiometer, turn the current LED all the way
on, all the way off, or somewhere in between
– The “in between” is the analog value
Where to go from Here?
● https://github.com/vuinguyen/ArduinoUnoBasics
● What types of projects would you like to build?
● Interest in hands-on workshop?
– For nominal fee through GDI (‘cause these workshops take a lot of
work to create!)
– We can help you build that cool thing you’ve been wanting to build
– Sign up for our email list to give us input
● Educators
– We can help you create a course for your students – just ask us!
● Please take our survey by Friday, September 22:
https://goo.gl/forms/7dn6avLltAg28StD2
The End
Thanks for Coming!
https://github.com/vuinguyen/ArduinoUnoBasics
Sunfishempire.com
@sunfishgurl
@infoGuideApps

More Related Content

What's hot (20)

Parte2 clase04 adc dca
Parte2 clase04 adc dca
Milton Gavilanez
 
AI Techniques for Smart Grids
AI Techniques for Smart Grids
Wilfried Elmenreich
 
LCD interfacing with arduino
LCD interfacing with arduino
Mrunal Deshkar
 
RISC-V Introduction
RISC-V Introduction
RISC-V International
 
VLSI Technology Evolution
VLSI Technology Evolution
Dr. A. B. Shinde
 
current mirrors
current mirrors
Mallavarapu Mounika
 
Smart grid ppt seminar topic
Smart grid ppt seminar topic
ramesh kumawat
 
Digital voltmeter project
Digital voltmeter project
kaushikbandopadhyay
 
What is Arduino ?
What is Arduino ?
Niket Chandrawanshi
 
Low power vlsi design
Low power vlsi design
Vinchipsytm Vlsitraining
 
Jumper wires
Jumper wires
Priyanka Jakhar
 
Kicad 101
Kicad 101
Ayan Pahwa
 
Lesson sample introduction to arduino
Lesson sample introduction to arduino
Betsy Eng
 
ADC using single slope technique
ADC using single slope technique
PoojashreeG
 
Lm 35
Lm 35
Makers of India
 
Network theory Interview & Viva
Network theory Interview & Viva
Engineering Funda
 
Esp8266 NodeMCU
Esp8266 NodeMCU
roadster43
 
What is FPGA?
What is FPGA?
GlobalLogic Ukraine
 
Spartan-II FPGA (xc2s30)
Spartan-II FPGA (xc2s30)
Dr. A. B. Shinde
 
Home automation using blynk app with fan direction control and displaying sta...
Home automation using blynk app with fan direction control and displaying sta...
Diwash Kapil Chettri
 

Similar to Intro to Hardware Programming with the Arduino Uno (20)

Intro_to_Arduino_-_v30_1.pdf
Intro_to_Arduino_-_v30_1.pdf
clementlesiba
 
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
MarkRenneyl
 
IntrotoArduino.ppt
IntrotoArduino.ppt
RohanBorgalli
 
Arduino Introduction.ppt
Arduino Introduction.ppt
ssuser631ea0
 
Intro_to_Arduino_v31_a_workshop_for_beginners
Intro_to_Arduino_v31_a_workshop_for_beginners
Yazan M. Allawi, Ph.D.
 
IntrotoArduino.ppt
IntrotoArduino.ppt
TalhaShahid49
 
Introductory level to Arduino programming
Introductory level to Arduino programming
ssuser5feb2c1
 
Intro_to_Arduino_-_v30.ppt
Intro_to_Arduino_-_v30.ppt
xdarlord
 
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
CarloCimacio
 
Intro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).ppt
HebaEng
 
Intro to arduino
Intro to arduino
BHUPATICh
 
Intro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.ppt
003AmanPratap
 
Arduino Measurefffffffffffffffffment.pdf
Arduino Measurefffffffffffffffffment.pdf
BILALFAROOQUI9
 
Arduino Programming.pdf
Arduino Programming.pdf
marygracelynquino1
 
Introduction to Arduino Version 3 Zero to Prototyping
Introduction to Arduino Version 3 Zero to Prototyping
versatilealligator
 
Intro_to_Arduino_Full_ppt_with_examples_and_excersices
Intro_to_Arduino_Full_ppt_with_examples_and_excersices
GeorgeTsak
 
Notes arduino workshop_15
Notes arduino workshop_15
Faiz Lazim
 
Fundamentals of Arduino: Day-01
Fundamentals of Arduino: Day-01
Redwan Ferdous
 
Arduino seminar report
Arduino seminar report
Zaka Jutt
 
Robotics and Embedded Systems
Robotics and Embedded Systems
Ankan Naskar
 
Intro_to_Arduino_-_v30_1.pdf
Intro_to_Arduino_-_v30_1.pdf
clementlesiba
 
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
Intro_to_AFrduinoFFFFFFFFFFF_-_v30_1.pdf
MarkRenneyl
 
Arduino Introduction.ppt
Arduino Introduction.ppt
ssuser631ea0
 
Intro_to_Arduino_v31_a_workshop_for_beginners
Intro_to_Arduino_v31_a_workshop_for_beginners
Yazan M. Allawi, Ph.D.
 
Introductory level to Arduino programming
Introductory level to Arduino programming
ssuser5feb2c1
 
Intro_to_Arduino_-_v30.ppt
Intro_to_Arduino_-_v30.ppt
xdarlord
 
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
CarloCimacio
 
Intro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).ppt
HebaEng
 
Intro to arduino
Intro to arduino
BHUPATICh
 
Intro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.ppt
003AmanPratap
 
Arduino Measurefffffffffffffffffment.pdf
Arduino Measurefffffffffffffffffment.pdf
BILALFAROOQUI9
 
Introduction to Arduino Version 3 Zero to Prototyping
Introduction to Arduino Version 3 Zero to Prototyping
versatilealligator
 
Intro_to_Arduino_Full_ppt_with_examples_and_excersices
Intro_to_Arduino_Full_ppt_with_examples_and_excersices
GeorgeTsak
 
Notes arduino workshop_15
Notes arduino workshop_15
Faiz Lazim
 
Fundamentals of Arduino: Day-01
Fundamentals of Arduino: Day-01
Redwan Ferdous
 
Arduino seminar report
Arduino seminar report
Zaka Jutt
 
Robotics and Embedded Systems
Robotics and Embedded Systems
Ankan Naskar
 
Ad

Recently uploaded (20)

Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Ad

Intro to Hardware Programming with the Arduino Uno

  • 1. Getting Started with the Arduino Uno by Eric J. Richardson and Vui Nguyen September 2017
  • 2. Legal Disclaimer Arduino is a trademark of somebody, certainly But not us
  • 3. Why this Presentation? ● Last year, we started doing IoT when we entered the Intel IoT Roadshow ●“Save the Water Pipes” was an automated faucet dripper – handy to prevent pipes from freezing and breaking in cold climates like Colorado! ● Vui: software architect ● Eric: hardware engineer ● Crystal: web developer
  • 4. Why this Presentation? ●We entered our project in the US-China Young Maker Competition (Sponsored by Intel) and competed in China! ● Vui presented our “Save the Water Pipes” project to Women Who Code ● Several of the Women Who Code had questions about the Intel Edison board which powered our project
  • 5. Why this Presentation? ● There was a lot of interest in the Intel Edison ● The Edison is cool, but at $100 it’s a bit pricey to get started with an embedded computing project ● so Eric did a follow up presentation at WWC on the Raspberry Pi ● Why the Raspberry Pi?
  • 6. Why this Presentation? ● Raspberry Pi is a great value, single-board computer, and can be used as the basis for many projects ● At Raspberry Pi presentation, Eric also provided a good overview of electronics and hardware concepts ● But there is a lot of setup with Raspberry Pi just to get started ● With Arduino Uno, you could get up and running much more quickly, for as much money, with less equipment and setup
  • 7. Who is this Presentation For? ● This presentation is for software devs interested in learning about hardware ● You should, by the end, know enough to get an Arduino Uno up and running, and writing Arduino sketches ● And, hopefully, driving electronic circuits ● We hope that we cover at least one thing you already know, and at least one thing you don't ● If you have a question about something, please ask! We may wave it off as something we cover later
  • 8. Personal Disclaimer For those of you who are already familiar with all of this, Eric apologizes if he sounds like he's “mansplaining”! He now has Vui co-presenting to help with this.
  • 9. Who Are We? Eric J. Richardson Lockheed Martin Systems Engineer Colorado State University B.S. Electrical & Computer Engineering, 2004 LIKES: DISLIKES: ● Antique Cars ● Dogs ● Shadowrun ● Cajun Food ● Old Video Games ● Hand Tools ● Cool Boots ● Cancer ● Fascism ● Lasagna ● TV Commercials Which Assume I'm Familiar with Sports Stars
  • 10. Who Are We? Vui Nguyen SimplyE iOS Developer Colorado School of Mines B.S. Computer Science, 1999 University of Denver M.S. Computer Science, 2006 LIKES: DISLIKES: ● Fishing ● Eating ● Fishing ● Traveling ● Fishing ● Dogs ● Fishing ● Not Fishing Enough ● Sexism ● Doing Dishes ● Negativity ● Being asked, “Where are you from?”
  • 11. Who Are We Not? ● We are not graphic artists! ● We are not full-fledged Arduino experts! ● We fully expect someone here to ask us a question we don't know the answer to
  • 12. What is “Arduino”? ● 3 things: – Arduino is an Italian company that designs low-cost computers designed to interact with physical hardware ● These are open-source hardware designs – “Arduino-compatible” boards have special I/O ports that allow the boards to be expanded with plugin-in modules called shields – It’s also the Arduino-specific programming language (based on C++) and IDE ● We will be working with the Arduino Uno board
  • 13. Arduino Uno: What Does It Have? Arduino Uno ● 14 Digital Input / Output pins (6 of these can be used as Analog outputs) ● 6 Analog inputs ● Atmel 8-bit microcontroller ● USB or plug-in power ● Arduino-compatible I/O; can plug in additional “shields” ● Ability to run Arduino sketches without any additional software installation ● Low-low price of ~$25
  • 14. Arduino Uno: What Does It NOT Have? The Arduino Uno does not have one of everything. Some things you can add, and some things you have to live without: ● Networking capability ● Multi-computing ● Native graphics or sound capability ● Case ● Huge Processing Power ● Full-blown O/S
  • 15. Arduino Uno: Required Equipment ● Arduino Uno ($25) ● USB A/B (male / male) cable ● 9V or 12V, center-pin-positive, 500mA (or more) power supply (optional)
  • 16. Electronics Mini-Lesson #1: Voltage, Current, Power, and Charge Direct-Current electricity has 4 dimensions: ● Voltage: How Hard The Electricity is Pushing – measured in Volts, or V (also mV) ● Current: How Much Electricity is Flowing Right Now – measured in Amperes, or Amps, or A (also mA) ● Power: How Much Work Electricity is Doing Right Now – measured in Watts, or W (also mW, kW, MW, etc.) ● Charge: How Much Electricity There Is – measured in Coulombs, or more usefully, Amp-Hours (also mAh)
  • 17. Electronics Mini-Lesson #1: Voltage, Current, Power, and Charge ● What we call a power supply is a constant-voltage source – That is, a power supply will deliver its rated output voltage up to its rated current output – So, a 19.5V power supply, rated for 6.7A of output, can deliver up to and including 6.7A without ill effect
  • 18. Electronics Mini-Lesson #1: Voltage, Current, Power, and Charge ● Power supplies can also deliver less than their rated current output! – They only deliver the current that the circuit “needs” (more on this later) – But, they always deliver the voltage that they are rated for (unless they are overloaded) ● So, you can use a power supply rated for more current than you need ● BUT, DO NOT use a power supply rated for more Voltage than you need!
  • 19. Electronics Mini-Lesson #1: Voltage, Current, Power, and Charge Electrical Power is always calculated by this formula: Power = Voltage x Current Or, if you prefer: Watts = Volts x Amps So, if you know the voltage and the current, you know the power being delivered. Back to our earlier example, the 6.7A @ 19.5V power supply is capable of delivering: 19.5V x 6.7A = 130W
  • 20. Electronics Mini-Lesson #1: Voltage, Current, Power, and Charge ● Batteries, as far as circuits are concerned, work the same as power supplies – A battery will deliver its rated voltage up to its rated current, though battery manufacturers do not always tell you the rated current ● The biggest difference is that you also have to worry about the charge of a battery, which you do not have to worry about with a power supply – A battery with a greater charge capacity (in amp- hours, or Ah) will “last” longer between chargings
  • 21. Arduino Uno: Optional Equipment ● breadboard ($5, but get 2, or 1 big one) ● Single Pole/Single Throw Normally Open Switch ($2) ● 1kΩ resistors ($1)
  • 22. Arduino Uno: Optional Equipment ● LED Assortment ($6) ● Male-to-Male Jumpers ($8) ● 1MΩ Potentiometers ($3)
  • 23. Install Arduino IDE ● Download and install Arduino IDE for your OS – https://www.arduino.cc/en/Guide/HomePage ● Follow instructions to “Install the board drivers”: – https://www.arduino.cc/en/Guide/ArduinoUno – And, from the same page, “Select your board type and port” ● Sample code to get started: – https://www.arduino.cc/en/Tutorial/BuiltInExamples
  • 24. Hardware Building Blocks ● We will going to focus the rest of this presentation on using the Arduino Uno as the basis of a hardware project ● This will take the form of the “Four Building Blocks” of physical computing: – Digital Output – Digital Input – Analog Output – Analog Input
  • 25. Hardware 100 – Blink an LED ● Before that, let's make sure the darn thing turn on ● Making sure you can get an LED to blink should always be the first thing you do with any new hardware project – It's the “Hello World” of hardware
  • 26. blinkOneLED ● Wire the green LED up like this: I/O 3 1kΩ
  • 27. blinkOneLED ● Physically, it will look something like this:
  • 28. Demonstration: blinkOneLED ● Let's make sure everything works!
  • 29. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits First, some terminology. This is a circuit diagram: + _Vin Voltage Source Load (resistor) + _ Current
  • 30. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits ● Current flows out of the positive (+) terminal of the Voltage Source, through the circuit, and into the (-) terminal of the Voltage Source ● The amount of current that flows is given by Ohm's Law: ● Where E is Voltage, I is current, and R is the Resistance of the load, in Ohms (Ω) ● Current I can also be express as: E = I x R I = E R
  • 31. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits ● So, for example, if Vin were 3.3V, and the load was 1kΩ, the current in this circuit would be 3.3V / 1000Ω = 3.3 mA ● What if we were to take the load out of the circuit? + _Vin
  • 32. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits ● In this case, current cannot flow, because there is no electrical path from the positive terminal of the voltage source to the negative one. ● This is called an open circuit. ● Think of it as an infinite-resistance load. – So, 3.3V / ∞Ω = 0A ● But what happens if we replace the load resistor with a wire?
  • 33. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits + _Vin Current? ● Wires have a resistance of 0Ω ● So, the current through the system is: 3.3V / 0Ω ● That would be infinite current, if the voltage source could supply infinite current!
  • 34. Electronics Mini-Lesson #2: Circuits, Open Circuits, and Short Circuits ● Instead, the voltage source will attempt to supply as much current as it can – enough to trip a circuit breaker, or more likely, burn up a wire, or the voltage source itself ● This is called a short circuit ● Do not wire up a short circuit! That's how you burn up components, and destroy circuit boards
  • 35. Electronics Mini-Lesson #3: GND and Vin Second, some shorthand. This takes time to draw: + _Vin
  • 36. Electronics Mini-Lesson #3: GND and Vin ● So, we will use two convenient shorthands. ● The positive terminal of the voltage source, and anything connected to it, we call Vin, or we just name it whatever the input voltage is (such as 3.3V) ● We denote it with this symbol: ● The negative terminal of the voltage source, and anything connected to it, we call GND (“ground”). ● We denote GND with this symbol: Vin
  • 37. Electronics Mini-Lesson #3: GND and Vin So: + _Vin Vin ==
  • 38. Electronics Mini-Lesson #4: Breadboards ● Breadboards are useful for wiring up circuit prototypes without soldering ● There are different types, but they mostly look something like this: ● The magic of a breadboard is that you can plug one wire into one hole, and have it be electrically connected to another wire plugged into another hole
  • 39. Electronics Mini-Lesson #4: Breadboards ● The electrical connections are arranged like so: ● It is helpful to plug Vin into the + rail, and GND into the – rail ● On either side of the channel are 5 pins all connected to each other
  • 40. Electronics Mini-Lesson #4: Breadboards ● Breadboards cannot carry infinite current without burning up! – If your circuit needs to carry more than about 500mA, I recommend not using a breadboard and jumpers: get some thicker-gauge, dedicated wires ● Breadboards cannot handle infinite voltage without arcing internally! – If your circuit needs to deliver more than about 24V, I recommend not using a breadboard and jumpers: get some wires with thicker insulation ● These numbers give a wide safety margin
  • 41. Electronics Mini-Lesson #5: LEDs ● “LED” stands for “Light Emitting Diode” ● They do not behave like resistors! We can model them like this: + _VD RD
  • 42. Electronics Mini-Lesson #5: LEDs ● VD is around 1.8V, while RD is not very much – on the order of 2Ω or so ● So, if you were to attach a 3.3V voltage source directly to the LED, you would get: ● This might not sound like much, but the output pins of the Arduino Uno can only output about 40mA or so apiece– if you were to “ask” them for 750mA, it could shut down or even damage the Arduino Uno (3.3V – 1.8V) / 2Ω = 750mA
  • 43. Electronics Mini-Lesson #5: LEDs ● This is why each LED needs a 1kΩ resistor in series with it: Vin 1kΩ ● If the LED is too dim, try a 470Ω resistor ● If the LED is too bright, try a 2kΩ resistor
  • 44. Electronics Mini-Lesson #5: LEDs ● Finally, LEDs are diodes, and the magic of a diode is that they only allow current to flow in one direction ● The flat part of the diode bulb, or the shorter of the two legs, should be oriented towards GND ● See http://media.bemyapp.com/control-led-lights/
  • 45. digitalOutputs.py ● Wire the green, yellow, and red LED up like this: I/O 3 1kΩ I/O 5 1kΩ I/O 6 1kΩ
  • 46. digitalOutputs ● Physically, it will look something like this:
  • 47. Demonstration: digitalOutputs ● Prepare to have your mind BLOWN! ● What it does: lights up a series of LEDs, one at a time, in round robin fashion ● The Magic: – Set LED pin mode to OUTPUT: we’re sending signals out to the LEDs, not receiving from them – Set digital write to HIGH to turn LED on – Set digital write to LOW to turn LED off – State is whether LED is currently on or off – Check state of current LED in loop to determine which LEDs need to be turned off/on
  • 48. digitalInput ● Leaving the LEDs in place, wire the switch like this: I/O 12 This is a single-throw switch. It only has one position in which the circuit is completed. For a “normally open” switch, the connection to GND will be made when you close the switch (press the button)
  • 49. digitalInput ● Physically, it will look something like this:
  • 50. Electronics Mini-Lesson #6: Pull-Ups / Pull- Downs When the switch is closed, the circuit will look like this: Now, the I/O pin is connected to GND, which the Arduino Uno will read as “LOW.” I/O 12
  • 51. Electronics Mini-Lesson #6: Pull-Ups / Pull- Downs What is I/O 12 connected to when the switch is open? ● It's not connected to LOW anymore, but it's also not connected to HIGH ● A digital input only has two options, so the Arduino Uno must read it as LOW or HIGH, but you don't know which one it will “pick” ● This is called a “floating input,” and it is bad, because you never know what you're going to get! I/O 12
  • 52. Electronics Mini-Lesson #6: Pull-Ups / Pull- Downs ● We can avoid floating inputs with “pull-up” and “pull-down” resistors ● A pull-up will leave the input pin to read HIGH in the absence of any other connection, while a pull-down will leave a floating input to read LOW ● The Arduino Uno can implement pull-ups (but NOT pull- downs) in code, as you will see ● Double-throw switches may not actually need pull-ups or pull-downs, but it won't hurt anything if you implement them anyway I/O 12 Vin
  • 53. Demonstration: digitalInput ● Pretty much the same as digitalOutputs, until you press the button ● What it does: Light up a series of LEDs, one at a time, in round robin robin. Press a button to make the LEDs light up in the opposite direction and at a faster speed. ● The Magic: – Same concepts as digitalOutputs, but this time uses an array of LED pins – For each LED pin in array, turns LED on, pauses, turns LED off – If button is not pressed, continue moving “forward” in turning LEDs on / off – If button is pressed, move backwards to turn LEDs on /off
  • 54. analogOutputs ● Wire the green, yellow, and red LED up like this: (same as digitalOutputs) I/O 3 1kΩ I/O 5 1kΩ I/O 6 1kΩ
  • 55. Arduino Uno I/O By the way, why did we pick pins 3, 5, and 6, of all the pins that we could have picked? Because those pins are 3 of the Input / Output pins that can also act as analog outputs (PWMs) These pins are denoted by the ~ symbol
  • 56. Electronics Mini-Lesson #7: Pulse Width Modulation ● Because of the nature of field-effect transistors, digital outputs – either HIGH or LOW – are easy for a computer to generate ● Analog outputs, which may have a value between HIGH and LOW – say, 1.7V, or 2.2V, or 3.1V – are NOT easy to generate ● However, since we mostly only need analog outputs for physical devices, which cannot instantly turn on and off, we can simulate an analog input by rapidly turning a digital signal off and on, and varying the percentage of time the signal is “on”
  • 57. Electronics Mini-Lesson #7: Pulse Width Modulation 0V 3.3V 0 m s 1 m s 2 m s 3 m s 4 m s 5 m s A 1kHz waveform, “off” for 50% of the time, and “on” for 50% of the time. The “duty cyle” is 50%. The output voltage is effectively half of the maximum, or 1.65V
  • 58. Electronics Mini-Lesson #7: Pulse Width Modulation 0V 3.3V 0 m s 1 m s 2 m s 3 m s 4 m s 5 m s This 1kHz waveform is “off” for 75% of the time, and “on” for 25% of the time. The “duty cyle” is 25%. The output voltage is effectively one-quarter of the maximum, or .825V
  • 59. Electronics Mini-Lesson #7: Pulse Width Modulation 0V 3.3V 0 m s 1 m s 2 m s 3 m s 4 m s 5 m s This 1kHz waveform is “off” for 25% of the time, and “on” for 75% of the time. The “duty cyle” is 75%. The output voltage is effectively three-quarters of the maximum, or 2.48V
  • 60. Electronics Mini-Lesson #7: Pulse Width Modulation ● This seems stupid, but it actually works very well for a variety of applications – Your car's fuel injectors – Throttling the electric motors in a quadcopter – Anti-lock brakes ● A PWM signal has two properties: the frequency and the duty cycle – The frequency should be fast enough that whatever you're driving operates smoothly, and slow enough to avoid high-frequency impedence
  • 61. Electronics Mini-Lesson #7: Pulse Width Modulation ● The PWM pins on the Arduino Uno are either 980 Hz (pins 5 and 6), or 490 Hz (pins 3, 9, 10, and 11) – Both of these frequencies are much too fast for the eye to notice an LED flickering ● The duty cycle can be anywhere between 0 (0%) and 255 (100%) – If you want a percentage duty cycle, you must multiply by 255 and divide by 100 to set the PWM
  • 62. Demonstration: analogOutputs ● Behold the wonders of Pulse Width Modulation! ● What It Does: Lights up a group of LEDs all at once, at different intervals/steps, from dimmest to brightest and back to dim again ● The Magic: – Instead of just turning on the LEDs all the way on or all the way off, analog output lets us light up the LED within a range of dimmer settings – The settings are in large intervals/steps
  • 63. Demonstration: analogOutputPulse ● This program shows what's possible with small changes in PWM duty cycle ● What It Does: Gradually lights up a group of LEDs all at once, from dimmest to brightest and back to dim again ● The Magic: ● Much like analogOutputs, except with PWM, the dimmer settings can be much smaller intervals / steps ● Changes in the dim settings can be much more gradual
  • 64. analogInput ● Finally, we have analog inputs ● Many times you wish to know not merely whether something is happening, but how much it is happening ● Many sensors – temperature sensors, light sensors, pressure sensors, etc. – will deliver an output voltage as a reaction to whatever they're sensing ● We will model this voltage with a potentiometer (variable resistor)
  • 65. analogInput ● Wire the green, yellow, and red LED up like this: (same as digitalOutputs) I/O 3 1kΩ I/O 5 1kΩ I/O 6 1kΩ
  • 66. analogInput ● And, wire the potentiometer up like this: +5V 10MΩ A0 The end terminals can be wired up in any direction, but the center terminal should point to the analog input pin
  • 67. analogInput ● Physically, it will look something like this:
  • 68. Demonstration: analogInput ● This program converts an analog input into an LED readout of sorts
  • 69. Demonstration: analogInput ● This effect would require a somewhat complicated circuit to implement if we weren't using the microcontroller ● What It Does: Gradually light up each LED, one at a time, as we turn up the knob on the potentiometer, and then gradually dim each LED, one at a time, as we turn down the knob on the potentiometer. ● The Magic: – Cycling through an array of LEDs, based on the value of the potentiometer, turn the current LED all the way on, all the way off, or somewhere in between – The “in between” is the analog value
  • 70. Where to go from Here? ● https://github.com/vuinguyen/ArduinoUnoBasics ● What types of projects would you like to build? ● Interest in hands-on workshop? – For nominal fee through GDI (‘cause these workshops take a lot of work to create!) – We can help you build that cool thing you’ve been wanting to build – Sign up for our email list to give us input ● Educators – We can help you create a course for your students – just ask us! ● Please take our survey by Friday, September 22: https://goo.gl/forms/7dn6avLltAg28StD2
  • 71. The End Thanks for Coming! https://github.com/vuinguyen/ArduinoUnoBasics Sunfishempire.com @sunfishgurl @infoGuideApps

Editor's Notes