SlideShare una empresa de Scribd logo
1 de 67
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Intro to Arduino
Diane Brancazio
adapted from
Sparkfun Intro to Arduino
by Linz Craig and Brian Huang
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…
is the go-to gear for artists, hobbyists,
students, and anyone with a gadgetry
dream.
rose out of another formidable challenge:
how to teach students to create
electronics, fast.
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.
Analog
INPUTS
Digital IO
PWM(3, 5, 6, 9, 10, 11)
PWR IN USB
(to Computer)
SCLSDA
(I2C Bus)
POWER
5V / 3.3V / GND
RESET
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Solderless connections on a
Breadboard?
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Solderless Breadboard
Each row (horiz.) of 5
holes are connected.
Vertical columns –
called power bus are
connected vertically
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
Referenced from the perspective of the microcontroller (electrical board).
Inputs is a signal / information
going into the board.
Output is any signal exiting the
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
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.
analog signals are anything that can be a full
range of values. What are some examples? More
on this later…
5 V
0 V
5 V
0 V
Arduino
Integrated Development Environment (IDE)
Two required functions /
methods / routines:
void setup()
{
// runs once
}
void loop()
{
// repeats
}error & status messages
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Settings: Tools → Serial Port
Your computer
communicates to the
Arduino microcontroller via a
serial port → through a USB-
Serial adapter.
Check to make sure that the
drivers are properly installed.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Settings: Tools → Board
Next, double-check that the proper board is selected under the
Tools→Board menu.
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.This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
BIG6CONCEPTS
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
Psuedo-code – how should this work?
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 is for single line comments
// it’s good to put a description at the
top and before anything ‘tricky’
/* this is for multi-line comments
Like this…
And this….
*/
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.
// NOTE: -> commands are CASE-sensitive
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #1: Wiring Diagram
Move the green
wire from the
power bus to pin
13 (or any other
Digital I/O pin on
the Arduino
board.
Image created in Fritzing
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.
Challenge 1b – blink to mimic a heartbeat
Challenge 1c – find the fastest blink that
the human eye can still detect…
1 ms delay? 2 ms delay? 3 ms
delay???
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:
8 bits 16 bits 32 bits
byte
char
int
unsigned int
long
unsigned long
float
This work is licensed 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 to
modify the output to mimic an analog
signal.
This is done by a technique called:
Pulse Width Modulation (PWM)
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Concepts: Analog vs. Digital
To create an analog signal, the microcontroller
uses a technique called PWM. By varying the duty
cycle, we can mimic an “average” analog voltage.
Pulse Width Modulation (PWM)
This work is licensed 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 ~ symbol
val – 8 bit value (0 – 255).
0 => 0V | 255 => 5V
Project #2 – Fading
Introducing a new command…
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
In Arduino, open up:
File → Examples → 01.Basics → Fade
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
Challenge 2a – Change the rate of the
fading in and out. There are at least two
different ways to do this – can you figure
them out?
Challenge 2b – Use 2 (or more) LEDs – so
that one fades in as the other one fades
out.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Color Mixing
Tri-color LED
In the SIK, this is a standard –
Common Cathode LED
This means the negative side of
the LED is all tied to Ground.
R G B
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project 3 – RGB LED
Note: The longest
leg of the RGB
LED is the
Common
Cathode. This
goes to GND.
Use pins 5, 6, & 9
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
NPN Transistor (Common Emitter “Amplifier” Circuit)
to Digital
Pin 9
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Input
Input is any signal entering an electrical system .
•Both digital and analog sensors are forms of input
•Input can also take many other forms: Keyboards, a
mouse, infrared sensors, biometric sensors, or just
plain voltage from a circuit
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Project #4 – Digital Input
In Arduino, open up:
File → Examples → 02.Digital → Button
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors (a.k.a. Switches)
Pull-up Resistor (Pull-up Resistor
(circuitPull-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
• 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)
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Digital Sensors
• Digital sensors are more straight forward than
Analog
• No matter what the sensor there are only two
settings: On and Off
• Signal is always either HIGH (On) or LOW (Off)
• Voltage signal for HIGH will be a little less than 5V on
your Uno
• Voltage signal for LOW will be 0V on most systems
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.
void loop()
{
int buttonState = digitalRead(5);
if(buttonState == LOW)
{ // do something
}
else
{ // do something else
}
}
Programming: Conditional Statements
if()
DIG
INPUT
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
wiper
fixed
end
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
1.0 V 1.0 V
wiper
fixed
ends
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()
Arduino uses a 10-bit A/D Converter:
• this means that you get input values from
0 to 1023
• 0 V → 0
• 5 V → 1023
Ex:
int sensorValue = analogRead(A0);
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Using Serial Communication
Method used to transfer data between two devices.
Arduino dedicates Digital I/O pin # 0 to
receiving and Digital I/O pin #1 to transmit.
Data passes between the computer and Arduino
through the USB cable. Data is transmitted as zeros
(‘0’) and ones (‘1’) sequentially.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
Serial Monitor & analogRead()
Initializes the Serial
Communication
9600 baud data rate
prints data to serial bus
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
Take two sensors -- Use
the Serial Monitor and find
the range of input values
you get for each sensor.
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
Prototypes: Document, Share, Teach, Manufacture
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
The rest of the class is dedicated to free pursuit
Experiment with the various circuits and lessons
in the SIK.
Explore the additional tutorials available on
learn.sparkfun.com
Thank you for attending our Intro to Arduino class
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

Más contenido relacionado

La actualidad más candente

blackboard architecture
blackboard architectureblackboard architecture
blackboard architecture
Nguyễn Ngân
 
Graphic Processing Unit
Graphic Processing UnitGraphic Processing Unit
Graphic Processing Unit
Kamran Ashraf
 

La actualidad más candente (20)

Hill climbing
Hill climbingHill climbing
Hill climbing
 
Raspberry PI
Raspberry PIRaspberry PI
Raspberry PI
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2
 
Self-supervised Learning from Video Sequences - Xavier Giro - UPC Barcelona 2019
Self-supervised Learning from Video Sequences - Xavier Giro - UPC Barcelona 2019Self-supervised Learning from Video Sequences - Xavier Giro - UPC Barcelona 2019
Self-supervised Learning from Video Sequences - Xavier Giro - UPC Barcelona 2019
 
OOP vs COP
OOP vs COPOOP vs COP
OOP vs COP
 
Computer Vision.pptx
Computer Vision.pptxComputer Vision.pptx
Computer Vision.pptx
 
Types of solar panel
Types of solar panelTypes of solar panel
Types of solar panel
 
FPGA/Reconfigurable computing (HPRC)
FPGA/Reconfigurable computing (HPRC)FPGA/Reconfigurable computing (HPRC)
FPGA/Reconfigurable computing (HPRC)
 
Solar Resource Assessment
Solar Resource AssessmentSolar Resource Assessment
Solar Resource Assessment
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
Screenless Display PPT
Screenless Display PPTScreenless Display PPT
Screenless Display PPT
 
Introduction to High Performance Computing
Introduction to High Performance ComputingIntroduction to High Performance Computing
Introduction to High Performance Computing
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Autoencoder
AutoencoderAutoencoder
Autoencoder
 
blackboard architecture
blackboard architectureblackboard architecture
blackboard architecture
 
Comparison of ACFS and DBFS
Comparison of ACFS and DBFSComparison of ACFS and DBFS
Comparison of ACFS and DBFS
 
Achieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAAchieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAA
 
Artificial Intelligence techniques
Artificial Intelligence techniquesArtificial Intelligence techniques
Artificial Intelligence techniques
 
Graphic Processing Unit
Graphic Processing UnitGraphic Processing Unit
Graphic Processing Unit
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 

Similar a Intro to Arduino.ppt

Intro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.pptIntro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.ppt
003AmanPratap
 
Intro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).pptIntro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).ppt
HebaEng
 

Similar a Intro to Arduino.ppt (20)

Intro_to_Arduino_-_v30_1.pdf
Intro_to_Arduino_-_v30_1.pdfIntro_to_Arduino_-_v30_1.pdf
Intro_to_Arduino_-_v30_1.pdf
 
Intro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.pptIntro_to_Arduino_with_coding_explained.ppt
Intro_to_Arduino_with_coding_explained.ppt
 
Intro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).pptIntro_to_Arduino_-_v30 (3).ppt
Intro_to_Arduino_-_v30 (3).ppt
 
IntrotoArduino.ppt
IntrotoArduino.pptIntrotoArduino.ppt
IntrotoArduino.ppt
 
Arduino Introduction.ppt
Arduino Introduction.pptArduino Introduction.ppt
Arduino Introduction.ppt
 
IntrotoArduino.ppt
IntrotoArduino.pptIntrotoArduino.ppt
IntrotoArduino.ppt
 
Intro to arduino
Intro to arduinoIntro to arduino
Intro to arduino
 
Intro_to_Arduino_-_v30.ppt
Intro_to_Arduino_-_v30.pptIntro_to_Arduino_-_v30.ppt
Intro_to_Arduino_-_v30.ppt
 
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
Intro_to_Arduino_-_v30dadasdadadadaasda.pptIntro_to_Arduino_-_v30dadasdadadadaasda.ppt
Intro_to_Arduino_-_v30dadasdadadadaasda.ppt
 
Intro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptxIntro_to_Arduino_-_v30.pptx
Intro_to_Arduino_-_v30.pptx
 
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 1.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 1.pdf
 
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 2.pdf
 
Arduino Development For Beginners
Arduino Development For BeginnersArduino Development For Beginners
Arduino Development For Beginners
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Advanced view arduino projects list use arduino for projects
Advanced view arduino projects list   use arduino for projectsAdvanced view arduino projects list   use arduino for projects
Advanced view arduino projects list use arduino for projects
 
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
 
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
 
Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!Lab Handson: Power your Creations with Intel Edison!
Lab Handson: Power your Creations with Intel Edison!
 
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdfAdvanced View Arduino Projects List - Use Arduino for Projects-2.pdf
Advanced View Arduino Projects List - Use Arduino for Projects-2.pdf
 
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdfAdvanced View Arduino Projects List - Use Arduino for Projects 5.pdf
Advanced View Arduino Projects List - Use Arduino for Projects 5.pdf
 

Más de jonathan Dietz (10)

Microbit robot assembly
Microbit robot assemblyMicrobit robot assembly
Microbit robot assembly
 
Microbit robot assembly
Microbit robot assemblyMicrobit robot assembly
Microbit robot assembly
 
Introduction to microbit-2
Introduction to microbit-2Introduction to microbit-2
Introduction to microbit-2
 
Introduction to microbit
Introduction to microbitIntroduction to microbit
Introduction to microbit
 
Week 7: Designing assessments and presentations of learning
Week 7: Designing assessments and presentations of learningWeek 7: Designing assessments and presentations of learning
Week 7: Designing assessments and presentations of learning
 
Module 6 art making, passion and motivation
Module 6  art making, passion and motivationModule 6  art making, passion and motivation
Module 6 art making, passion and motivation
 
Module 5 integrating technology skills, engineering design, and coding
Module 5  integrating technology skills, engineering design, and codingModule 5  integrating technology skills, engineering design, and coding
Module 5 integrating technology skills, engineering design, and coding
 
Module 4 Integrating english language arts and mathematics (1)
Module 4   Integrating english language arts and mathematics (1)Module 4   Integrating english language arts and mathematics (1)
Module 4 Integrating english language arts and mathematics (1)
 
Module 3 21st century skills creativity, critical thinking, communication...
Module 3   21st century skills   creativity, critical thinking, communication...Module 3   21st century skills   creativity, critical thinking, communication...
Module 3 21st century skills creativity, critical thinking, communication...
 
Week 2 Project based learning
Week 2    Project based learningWeek 2    Project based learning
Week 2 Project based learning
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Último (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Intro to Arduino.ppt

  • 1. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Intro to Arduino Diane Brancazio adapted from Sparkfun Intro to Arduino by Linz Craig and Brian Huang
  • 2. 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)
  • 3. This work is licensed 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 gadgetry dream. rose out of another formidable challenge: how to teach students to create electronics, fast. http://spectrum.ieee.org/geek-life/hands-on/the-making-of-arduino
  • 4. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Analog INPUTS Digital IO PWM(3, 5, 6, 9, 10, 11) PWR IN USB (to Computer) SCLSDA (I2C Bus) POWER 5V / 3.3V / GND RESET
  • 5. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Solderless connections on a Breadboard?
  • 6. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Solderless Breadboard Each row (horiz.) of 5 holes are connected. Vertical columns – called power bus are connected vertically
  • 7. 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!!!
  • 8. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Concepts: INPUT vs. OUTPUT Referenced from the perspective of the microcontroller (electrical board). Inputs is a signal / information going into the board. Output is any signal exiting the 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
  • 9. 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. analog signals are anything that can be a full range of values. What are some examples? More on this later… 5 V 0 V 5 V 0 V
  • 10. Arduino Integrated Development Environment (IDE) Two required functions / methods / routines: void setup() { // runs once } void loop() { // repeats }error & status messages
  • 11. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Settings: Tools → Serial Port Your computer communicates to the Arduino microcontroller via a serial port → through a USB- Serial adapter. Check to make sure that the drivers are properly installed.
  • 12. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Settings: Tools → Board Next, double-check that the proper board is selected under the Tools→Board menu.
  • 13. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Arduino & Arduino Compatible Boards
  • 14. 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. BIG6CONCEPTS
  • 15. 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 Psuedo-code – how should this work?
  • 16. 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 is for single line comments // it’s good to put a description at the top and before anything ‘tricky’ /* this is for multi-line comments Like this… And this…. */
  • 17. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. comments
  • 18. 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. // NOTE: -> commands are CASE-sensitive
  • 19. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Project #1: Wiring Diagram Move the green wire from the power bus to pin 13 (or any other Digital I/O pin on the Arduino board. Image created in Fritzing
  • 20. 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. Challenge 1b – blink to mimic a heartbeat Challenge 1c – find the fastest blink that the human eye can still detect… 1 ms delay? 2 ms delay? 3 ms delay???
  • 21. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Try adding other LEDs
  • 22. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Programming Concepts: Variables Variable Scope Global --- Function-level
  • 23. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Programming Concepts: Variable Types Variable Types: 8 bits 16 bits 32 bits byte char int unsigned int long unsigned long float
  • 24. This work is licensed 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 to modify the output to mimic an analog signal. This is done by a technique called: Pulse Width Modulation (PWM)
  • 25. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Concepts: Analog vs. Digital To create an analog signal, the microcontroller uses a technique called PWM. By varying the duty cycle, we can mimic an “average” analog voltage. Pulse Width Modulation (PWM)
  • 26. This work is licensed 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 ~ symbol val – 8 bit value (0 – 255). 0 => 0V | 255 => 5V Project #2 – Fading Introducing a new command…
  • 27. 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 In Arduino, open up: File → Examples → 01.Basics → Fade
  • 28. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Fade - Code Review
  • 29. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Fade - Code Review
  • 30. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Project# 2 -- Fading Challenge 2a – Change the rate of the fading in and out. There are at least two different ways to do this – can you figure them out? Challenge 2b – Use 2 (or more) LEDs – so that one fades in as the other one fades out.
  • 31. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Color Mixing Tri-color LED In the SIK, this is a standard – Common Cathode LED This means the negative side of the LED is all tied to Ground. R G B
  • 32. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Project 3 – RGB LED Note: The longest leg of the RGB LED is the Common Cathode. This goes to GND. Use pins 5, 6, & 9
  • 33. 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.
  • 34. 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); }
  • 35. 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); }
  • 36. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Project: Mood Lamp / Light Sculpture
  • 37. 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.
  • 38. 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.
  • 39. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Driving Motors or other High Current Loads NPN Transistor (Common Emitter “Amplifier” Circuit) to Digital Pin 9
  • 40. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Input Input is any signal entering an electrical system . •Both digital and analog sensors are forms of input •Input can also take many other forms: Keyboards, a mouse, infrared sensors, biometric sensors, or just plain voltage from a circuit
  • 41. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Project #4 – Digital Input In Arduino, open up: File → Examples → 02.Digital → Button
  • 42. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Digital Sensors (a.k.a. Switches) Pull-up Resistor (Pull-up Resistor (circuitPull-up Resistor (circuit) to Digital Pin 2
  • 43. 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!
  • 44. This work is licensed 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)
  • 45. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Digital Sensors • Digital sensors are more straight forward than Analog • No matter what the sensor there are only two settings: On and Off • Signal is always either HIGH (On) or LOW (Off) • Voltage signal for HIGH will be a little less than 5V on your Uno • Voltage signal for LOW will be 0V on most systems
  • 46. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.http://opensourcehardwarejunkies.com/tutorial-03-digitalread-and-
  • 47. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Programming: Conditional Statements if()
  • 48. This work is licensed 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 Statements if() DIG INPUT
  • 49. 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
  • 50. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Trimpot (Potentiometer) Variable Resistor wiper fixed end fixed end
  • 51. 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 1.0 V 1.0 V wiper fixed ends
  • 52. 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”
  • 53. This work is licensed 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 values from 0 to 1023 • 0 V → 0 • 5 V → 1023 Ex: int sensorValue = analogRead(A0);
  • 54. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Using Serial Communication Method used to transfer data between two devices. Arduino dedicates Digital I/O pin # 0 to receiving and Digital I/O pin #1 to transmit. Data passes between the computer and Arduino through the USB cable. Data is transmitted as zeros (‘0’) and ones (‘1’) sequentially.
  • 55. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Serial Monitor & analogRead() Initializes the Serial Communication 9600 baud data rate prints data to serial bus
  • 56. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Serial Monitor & analogRead() Opens up a Serial Terminal Window
  • 57. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Analog Sensors 2 Pin Analog Sensors = var. resistor Take two sensors -- Use the Serial Monitor and find the range of input values you get for each sensor. MaxAnalogRead = _________ MinAnalogRead = _________
  • 58. 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
  • 59. 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!!!”) ; }
  • 60. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License.
  • 61. 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 ) ; }
  • 62. 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)); }
  • 63. 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 Prototypes: Document, Share, Teach, Manufacture
  • 64. 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
  • 65. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Free Time The rest of the class is dedicated to free pursuit Experiment with the various circuits and lessons in the SIK. Explore the additional tutorials available on learn.sparkfun.com Thank you for attending our Intro to Arduino class
  • 66. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License. Questions?
  • 67. 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