Intro to ArduinoZeroto Prototypingin a Flash!Material designed by Linz Craig, Nick Poole, Prashanta Aryal,Theo Simpson, Tai Johnson, and Eli Santistevan
2.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Overview of ClassGetting Started:Installation, Applications and MaterialsElectrical:Components, Ohm's Law, Input and Output, Analog and Digital-----------------------------Programming:Split into groups depending on experienceSerial Communication Basics:Troubleshooting and DebuggingVirtual Prototyping:Schematics and PCB Layout in Fritzing
3.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Arduino Board“Strong Friend” Created in Ivrea, Italyin 2005 by Massimo Banzi & David CuartiellesOpen Source HardwareProcessorCoding is accessible & transferrable (C++, Processing, java)
4.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Arduino…is the go-to gear for artists, hobbyists,students, and anyone with a gadgetrydream.rose out of another formidable challenge:how to teach students to createelectronics, fast.http://spectrum.ieee.org/geek-life/hands-on/the-making-of-arduino
5.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Getting Started• SW Installation: Arduino (v.1.0+)FritzingSIK Guide CodeDrivers (FTDI)• Materials: SIK GuideAnalog I/O, Digital I/O, Serial, &Fritzing handoutsArduino CheatSheet
6.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.AnalogINPUTSDigital IOPWM(3, 5, 6, 9, 10, 11)PWR IN USB(to Computer)SCLSDA(I2C Bus)POWER5V / 3.3V / GNDRESET
7.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.AnalogINPUTSDigital IOPWM(3, 5, 6, 9, 10, 11)PWR IN USB(to Computer)SCLSDA(I2C Bus)POWER5V / 3.3V / GNDRESET
8.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Go ahead and plug your board in!
9.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Arduino ShieldsPCB Built Shield Inserted Shield
10.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Arduino ShieldsMicro SD MP3 Trigger LCD
11.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.SIK ComponentsPush Button Digital Input Switch - Closesor opens circuitPolarized, needsresistorTrimpotentiometerAnalog Input Variable resistor Also called aTrimpot.Photoresistor Analog Input Light DependentResistor (LDR)Resistance varieswith light.Relay Digital Output Switch driven bya small signalUsed to controllarger voltagesTemp Sensor Analog Input Temp DependentResistorFlex Sensor Analog Input Variable resistorSoft Trimpot Analog Input Variable resistor Careful of shortsRGB LED Dig & AnalogOutput16,777,216different colorsOoh... So pretty.Name Image Type Function Notes
12.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.SIK Components
13.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.SIK Components
14.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.SIK Components
15.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
16.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Electricity Electronics Basic ConceptReview• Ohms Law• Voltage• Current• Resistance• Using a Multi-meter
17.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Ohm’s Law
18.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Electrical Properties
19.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Current Flow AnalogyHigh Current Low Current
20.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.WaterTowerVoltage AnalogyMore Energy == Higher Voltage Less Energy == Lower VoltageVWaterTowerV
21.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Resistance AnalogyBig Pipe == Lower Resistance Small Pipe == Higher ResistanceWaterTowerWaterTowerV
22.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Continuity – Is it a Circuit?The word “circuit” is derived from the circle. AnElectrical Circuit must have a continuous LOOPfrom Power (Vcc) to Ground (GND).Continuity is important to make portions of circuitsare connect. Continuity is the simplest andpossibly the most important setting on your multi-meter. Sometimes we call this “ringing out” acircuit.
23.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Measuring Electricity – VoltageVoltage is a measure of potential electricalenergy. A voltage is also called a potentialdifference – it is measured between twopoints in a circuit – across a device.
24.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Measuring Electricity -- CurrentCurrent is the measure of the rate of charge flow.For Electrical Engineers – we consider this to bethe movement of electrons.In order to measure this – you must break the circuitor insert the meter in-line (series).
25.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Measuring Electricity -- ResistanceResistance is the measure of how much oppositionto current flow is in a circuit.Components should be removed entirely from thecircuit to measure resistance. Note the settings onthe multi-meter. Make sure that you are set forthe appropriate range.Resistancesettings
26.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Prototyping CircuitsSolderless BreadboardOne of the most useful tools in an engineeror Maker’s toolkit. The three mostimportant things:• A breadboard is easier than soldering• A lot of those little holes are connected, which ones?• Sometimes breadboards break
27.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.What’s a Breadboard?
28.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Solderless BreadboardEach row (horiz.) of 5holes are connected.Vertical columns –called power bus areconnected vertically
29.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Using the Breadboard to built a simplecircuitUse the breadboardto wire up a singleLED with a 330 OhmResistor (Orange-Orange-Brown).Note: the longer leg on theLED is the positive leg andthe shorter leg is thenegative
30.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Fritzing View of Breadboard CircuitWhat happenswhen you breakthe circuit?What if youwanted to addmore than oneLED?
31.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Adding control – let’s use the Arduinoand start programming!!!
32.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Concepts: INPUT vs. OUTPUTReferenced from the perspective of the microcontroller (electricalboard).Inputs is a signal /information going into theboard.Output is any signal exitingthe board.Almost all systems that use physical computing will havesome form of outputWhat are some examples of Outputs?
33.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Concepts: INPUT vs. OUTPUTReferenced from the perspective of the microcontroller (electricalboard).Inputs is a signal /information going into theboard.Output is any signal exitingthe board.Examples: Buttons Switches,Light Sensors, Flex Sensors,Humidity Sensors,Temperature Sensors…Examples: LEDs, DC motor,servo motor, a piezo buzzer,relay, an RGB LED
34.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Concepts: Analog vs. DigitalMicrocontrollers are digital devices – ON orOFF. Also called – discrete.analog signals are anything that can be a fullrange of values. What are some examples?More on this later…5 V0 V5 V0 V
35.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Open up ArduinoHints:For PC Users 1.Let the installer copyand move the files to theappropriate locations, or2.Create a folder underC:Program Files (x86)called Arduino. Move theentire Arduino programfolder here.For Mac Users 1. Move the Arduinoexecutable to the dockfor ease of access.2. Resist the temptationto run these from yourdesktop.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Settings: Tools Serial PortYour computercommunicates to theArduino microcontroller viaa serial port through aUSB-Serial adapter.Check to make sure thatthe drivers are properlyinstalled.
38.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Settings: Tools BoardNext, double-check that the proper board is selected underthe ToolsBoard menu.
39.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Arduino & Arduino Compatible Boards
40.
This work islicensed 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.BIG6CONCEPTS
41.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Let’s get to coding…Project #1 – Blink“Hello World” of Physical ComputingPsuedo-code – how should this work?
42.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Comments, Comments, CommentsComments are for you – the programmer and your friends…or anyone else human that might read your code.// this is for single line comments// it’s good to put a description at the topand before anything ‘tricky’/* this is for multi-line commentsLike this…And this….*/
43.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.comments
44.
This work islicensed 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.// NOTE: -> commands are CASE-sensitive
45.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Project #1: Wiring DiagramMove the greenwire from thepower bus to pin13 (or any otherDigital I/O pin onthe Arduino board.Image created in Fritzing
46.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.A few simple challengesLet’s make LED#13 blink!Challenge 1a – blink with a 200 ms secondinterval.Challenge 1b – blink to mimic a heartbeatChallenge 1c – find the fastest blink that thehuman eye can still detect…1 ms delay? 2 ms delay? 3 ms delay???
47.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Try adding other LEDs
48.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Programming Concepts: VariablesVariable ScopeGlobal---Function-level
49.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Programming Concepts: VariableTypesVariable Types:8 bits 16 bits 32 bitsbytecharintunsigned intlongunsigned longfloat
50.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Fading in and Fading Out(Analog or Digital?)A few pins on the Arduino allow for us tomodify the output to mimic an analogsignal.This is done by a technique called:Pulse Width Modulation (PWM)
51.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Concepts: Analog vs. DigitalTo create an analog signal, the microcontrolleruses a technique called PWM. By varying the dutycycle, we can mimic an “average” analog voltage.Pulse Width Modulation (PWM)
52.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.analogWrite(pin, val);pin – refers to the OUTPUT pin(limited to pins 3, 5, 6, 9, 10,11.) – denoted by a ~ symbolval – 8 bit value (0 – 255).0 => 0V | 255 => 5VProject #2 – FadingIntroducing a new command…
53.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Move one of your LED pins over to Pin9In Arduino, open up:File Examples 01.Basics Fade
54.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Fade - Code Review
55.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Fade - Code Review
56.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Project# 2 -- FadingChallenge 2a – Change the rate of thefading in and out. There are at least twodifferent ways to do this – can youfigure them out?Challenge 2b – Use 2 (or more) LEDs – sothat one fades in as the other one fadesout.
57.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Color MixingTri-color LEDIn the SIK, this is a standard –Common Cathode LEDThis means the negative sideof the LED is all tied to Ground.R G B
58.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Project 3 – RGB LEDNote: The longestleg of the RGBLED is theCommonCathode. Thisgoes to GND.Use pins 5, 6, & 9
59.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.How many unique colors can youcreate?Use Colorpicker.com orexperiment on yourown.Pick out a few colors thatyou want to try re-creating for a lamp orlighting display...Play around with this withthe analogWrite()command.
60.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.RGB LED Color Mixingint redPin = 5;int greenPin = 6;int bluePin = 9;void setup(){pinMode(redPin, OUTPUT);pinMode(greenPin, OUTPUT);pinMode(bluePin, OUTPUT);}
61.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.RGB LED Color Mixingvoid loop(){analogWrite(redPin, 255);analogWrite (greenPin, 255);analogWrite (bluePin, 255);}
62.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Project: Mood Lamp / Light Sculpture
63.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.NapkinSchematicsEmphasize theengineering designprocess withstudents. We like toskirt the linebetween formaland informal with atool called NapkinSchematics.
64.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.NapkinSchematicsEmphasize theengineering designprocess withstudents. We like toskirt the linebetween formaland informal with atool called NapkinSchematics.
65.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Driving Motors or other High CurrentLoadsNPN Transistor (Common Emitter “Amplifier” Circuit)to DigitalPin 9
66.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.InputInput is any signal entering an electrical system .•Both digital and analog sensors are forms of input•Input can also take many other forms: Keyboards, amouse, infrared sensors, biometric sensors, or justplain voltage from a circuit
67.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Project #4 – Digital InputIn Arduino, open up:File Examples 02.Digital Button
68.
This work islicensed 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
69.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Digital Sensors (a.k.a. Switches)Add an indicator LED to Pin 13This is just like our1stcircuit!
70.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Digital Input• Connect digital input to your Arduino using Pins # 0 – 13(Although pins # 0 & 1 are also used for programming)• Digital Input needs a pinMode command:pinMode (pinNumber, INPUT);Make sure to use ALL CAPS for INPUT• To get a digital reading:int buttonState = digitalRead (pinNumber);• Digital Input values are only HIGH (On) or LOW (Off)
71.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Digital Sensors• Digital sensors are more straight forward thanAnalog• No matter what the sensor there are only twosettings: On and Off• Signal is always either HIGH (On) or LOW (Off)• Voltage signal for HIGH will be a little less than 5Von your Uno• Voltage signal for LOW will be 0V on most systems
72.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-
73.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Programming: Conditional Statementsif()
74.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.void loop(){int buttonState = digitalRead(5);if(buttonState == LOW){ // do something}else{ // do something else}}Programming: Conditional Statementsif()DIGINPUT
75.
This work islicensed 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
76.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Trimpot (Potentiometer)Variable Resistorwiperfixedendfixedend
77.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Analog Sensors3 Pin Potentiometer = var. resistor (circuit)a.k.a. Voltage Divider Circuit1.0 V 1.0 Vwiperfixedends
78.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Ohms Law… (just the basics)Actually, this is the “voltage divider”
79.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.analogRead()Arduino uses a 10-bit A/D Converter:• this means that you get input valuesfrom 0 to 1023• 0 V 0• 5 V 1023Ex:int sensorValue = analogRead(A0);
80.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Using Serial CommunicationMethod used to transfer data between twodevices.Arduino dedicates Digital I/O pin # 0 toreceiving and Digital I/O pin #1 totransmit.Data passes between the computer and Arduinothrough the USB cable. Data is transmitted aszeros (‘0’) and ones (‘1’) sequentially.
81.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Serial Monitor & analogRead()Initializes the SerialCommunication9600 baud data rateprints data to serial bus
82.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Serial Monitor & analogRead()Opens up aSerial TerminalWindow
83.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Analog Sensors2 Pin Analog Sensors = var. resistorTake two sensors -- Usethe Serial Monitor andfind the range of inputvalues you get for eachsensor.MaxAnalogRead = _________MinAnalogRead = _________
84.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Analog SensorsExamples:Sensors VariablesMic soundVolumePhotoresistor lightLevelPotentiometer dialPositionTemp Sensor temperatureFlex Sensor bendAccelerometer tilt/acceleration
85.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Additional Serial CommunicationSending a Messagevoid loop ( ){Serial.print(“Hands on “) ;Serial.print(“Learning ”) ;Serial.println(“is Fun!!!”) ;}
86.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
87.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Serial Communication:Serial Debuggingvoid loop(){int xVar = 10;Serial.print ( “Variable xVar is “ ) ;Serial.println ( xVar ) ;}
88.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Serial Communication:Serial Troubleshootingvoid loop ( ){Serial.print (“Digital pin 9: “);Serial.println (digitalRead(9));}
89.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Virtual Electrical Prototyping Projectstarted in 2007 by the Interaction Design Labat the University of Applied Science Potsdam, GermanyOpen SourcePrototypes: Document, Share, Teach, Manufacture
90.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Now that you feel comfortable putting togethercircuits with your breadboard let’s talk abouthow to go from the breadboard to a PCB
91.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Free TimeThe rest of the class is dedicated to free pursuitExperiment with the various circuits andlessons in the SIK.Explore the additional tutorials available onlearn.sparkfun.comThank you for attending our Intro to Arduinoclass
92.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.Questions?
93.
This work islicensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.www.sparkfun.com6175 Longbow Drive, Suite 200Boulder, Colorado 80301
#37 Be sure to point out the what all of the buttons do.
#38 All connections to computers- mice, printers etc use a serial port. Gotta pick the right one.
#39 All connections to computers- mice, printers etc use a serial port. Gotta pick the right one.
#44 Review the two main parts of the sketch – void setup() and void loop()Provide rationale for good commenting.Emphasize the need for good / clean coding practices like indenting.
#45 Three commands to rule the world… or at least do 80% of cool Arduino projects.
#63 Here are a few examples of project ideas that you can extend this to in the class.