Introto Arduino
Introto Arduino
Zero to Prototyping
in a Flash!
Getting Started:
Installation, Applications and Materials
Electrical:
Components, Ohm's Law, Input and Output, Analog and Digital
-----------------------------
Programming:
Split into groups depending on experience
Serial Communication Basics:
Troubleshooting and Debugging
Virtual Prototyping:
Schematics and PCB Layout in Fritzing
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino Board
“Strong Friend” Created in Ivrea, Italy
in 2005 by Massimo Banzi & David Cuartielles
Open Source Hardware
Processor
Coding is accessible & transferrable (C++, Processing, java)
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino…
http://spectrum.ieee.org/geek-life/hands-on/the-making-of-arduino
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Getting Started
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
PWR IN USB
(to Computer)
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
PWR IN USB
(to Computer)
RESET
SCL\SDA
(I2C Bus)
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Go ahead and plug your board in!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino Shields
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino Shields
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
SIK Components
Name Image Type Function Notes
Push Button Digital Input Switch - Closes Polarized, needs
or opens circuit resistor
Trim Analog Input Variable resistor Also called a
Trimpot.
potentiometer
Photoresistor Analog Input Light Dependent Resistance varies
Resistor (LDR) with light.
Relay Digital Output Switch driven by Used to control
a small signal larger voltages
Temp Sensor Analog Input Temp Dependent
Resistor
Flex Sensor Analog Input Variable resistor
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
SIK Components
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
SIK Components
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
SIK Components
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Electricity \ Electronics Basic Concept
Review
• Ohms Law
• Voltage
• Current
• Resistance
• Using a Multi-meter
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Ohm’s Law
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Electrical Properties
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Current Flow Analogy
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Voltage Analogy
Water
Tower
Water
Tower
V
V
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Resistance Analogy
Water Water
Tower Tower
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Continuity – Is it a Circuit?
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Measuring Electricity – Voltage
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Measuring Electricity -- Current
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Measuring Electricity -- Resistance
Resistance
settings
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Prototyping Circuits
Solderless Breadboard
One of the most useful tools in an engineer or
Maker’s toolkit. The three most important things:
• A breadboard is easier than soldering
• A lot of those little holes are connected, which ones?
• Sometimes breadboards break
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
What’s a Breadboard?
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Solderless Breadboard
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Using the Breadboard to built a simple circuit
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fritzing View of Breadboard Circuit
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Adding control – let’s use the Arduino
and start programming!!!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: INPUT vs. OUTPUT
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: Analog vs. Digital
Microcontrollers are digital devices – ON or OFF.
Also called – discrete.
5V 5V
0V 0V
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Open up Arduino
Hints:
For PC Users For Mac Users
1. Let the installer copy and 1. Move the Arduino
move the files to the executable to the dock for
appropriate locations, or ease of access.
2. Create a folder under 2. Resist the temptation to
C:\Program Files (x86) run these from your
called Arduino. Move the desktop.
entire Arduino program
folder here.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino
Integrated Development Environment (IDE)
void setup()
{
// runs once
}
void loop()
{
// repeats
error & status messages }
Settings: Tools Serial Port
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Settings: Tools Board
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Arduino & Arduino Compatible Boards
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
BIG 6 CONCEPTS
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Let’s get to coding…
Project #1 – Blink
“Hello World” of Physical Computing
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Comments, Comments, Comments
Comments are for you – the programmer and your friends…or
anyone else human that might read your code.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
comments
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Three commands to know…
pinMode(pin, INPUT/OUTPUT);
ex: pinMode(13, OUTPUT);
digitalWrite(pin, HIGH/LOW);
ex: digitalWrite(13, HIGH);
delay(time_ms);
ex: delay(2500); // delay of 2.5 sec.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #1: Wiring Diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
A few simple challenges
Let’s make LED#13 blink!
Challenge 1a – blink with a 200 ms second interval.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Try adding other LEDs
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming Concepts: Variables
Variable Scope
Global
---
Function-level
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming Concepts: Variable Types
Variable Types:
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: Analog vs. Digital
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #2 – Fading
Introducing a new command…
analogWrite(pin, val);
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Move one of your LED pins over to Pin 9
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fade - Code Review
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Fade - Code Review
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project# 2 -- Fading
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
R G B
Color Mixing
Tri-color LED
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project 3 – RGB LED
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
How many unique colors can you create?
Use Colorpicker.com or
experiment on your own.
Pick out a few colors that
you want to try re-creating
for a lamp or lighting
display...
Play around with this with
the analogWrite()
command.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
RGB LED Color Mixing
int redPin = 5;
int greenPin = 6;
int bluePin = 9;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
RGB LED Color Mixing
void loop()
{
analogWrite(redPin, 255);
analogWrite (greenPin, 255);
analogWrite (bluePin, 255);
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project: Mood Lamp / Light Sculpture
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Napkin
Schematics
Emphasize the
engineering design
process with students.
We like to skirt the
line between formal
and informal with a
tool called Napkin
Schematics.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Napkin
Schematics
Emphasize the
engineering design
process with students.
We like to skirt the
line between formal
and informal with a
tool called Napkin
Schematics.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Driving Motors or other High Current Loads
to Digital
Pin 9
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Input
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #4 – Digital Input
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors (a.k.a. Switches)
Pull-up Resistor (circuit)
to Digital Pin 2
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors (a.k.a. Switches)
Add an indicator LED to Pin 13
This is just like our
1st circuit!
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Input
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming: Conditional Statements
if()
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Programming: Conditional Statements
if()
void loop()
{
int buttonState = digitalRead(5);
if(buttonState == LOW)
{ // do something DIG
INPUT
}
else
{ // do something else
}
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Boolean Operators
<Boolean> Description
( ) == ( ) is equal?
( ) != ( ) is not equal?
( ) > ( ) greater than
( ) >= ( ) greater than or equal
( ) < ( ) less than
( ) <= ( ) less than or equal
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Trimpot (Potentiometer)
Variable Resistor
fixed
end
wiper
fixed
end
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Analog Sensors
3 Pin Potentiometer = var. resistor (circuit)
a.k.a. Voltage Divider Circuit
wiper
fixed
ends 1.0 V 1.0 V
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Ohms Law… (just the basics)
Actually, this is the “voltage divider”
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
analogRead()
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Using Serial Communication
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Monitor & analogRead()
Opens up a
Serial Terminal
Window
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Analog Sensors
2 Pin Analog Sensors = var. resistor
MaxAnalogRead = _________
MinAnalogRead = _________
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Analog Sensors
Examples:
Sensors Variables
Mic soundVolume
Photoresistor lightLevel
Potentiometer dialPosition
Temp Sensor temperature
Flex Sensor bend
Accelerometer tilt/acceleration
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Additional Serial Communication
Sending a Message
void loop ( )
{
Serial.print(“Hands on “) ;
Serial.print(“Learning ”) ;
Serial.println(“is Fun!!!”) ;
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Communication:
Serial Debugging
void loop()
{
int xVar = 10;
Serial.print ( “Variable xVar is “ ) ;
Serial.println ( xVar ) ;
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Communication:
Serial Troubleshooting
void loop ( )
{
Serial.print (“Digital pin 9: “);
Serial.println (digitalRead(9));
}
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Virtual Electrical Prototyping Project
started in 2007 by the Interaction Design Lab
at the University of Applied Science Potsdam, Germany
Open Source
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Now that you feel comfortable putting together circuits
with your breadboard let’s talk about how to go from
the breadboard to a PCB
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Free Time
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Questions?
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
www.sparkfun.com
6175 Longbow Drive, Suite 200
Boulder, Colorado 80301
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.