LilyPad Dev at Artisan`s Asylum

download report

Transcript LilyPad Dev at Artisan`s Asylum

Intro to Arduino with
LilyPad
Make a MakerSpace, Artisan’s Asylum
Linz Craig, Chris Taylor,
Mike Hord & Joel Bartlett
Overview of Class
Getting Started:
Installation and Applications
Electrical:
Components, Input and Output, Analog and Digital
Trouble Shooting:
Serial Communication
Additional Teaching Tools:
Giant Components and Breadboard, Free Teaching Materials
Arduino Board
“Strong Friend” Created in Ivrea, Italy
in 2005 by Massimo Banzi & David Cuartielles
Open Source Hardware
Atmel Processor
Coding is accessible (C++, Processing, ModKit and MiniBloq)
The LilyPad Dev Board
Flip the Board Over
Do you see the wires that are running to the sensors,
LEDs, and buttons?
The microcontroller can already talk to the inputs and
outputs!
Board Type
Other Board Type
Serial Port / COM Port
Analog and Digital
• All Arduino signals are either Analog or
Digital
• All computers including Arduino, only
understand Digital
• It is important to understand the difference
between Analog and Digital signals since
Analog signals require an Analog to Digital
conversion
Output
Output is always Digital
To Output a Digital signal (On or Off) use this code:
digitalWrite ( pinNumber , value );
Where value is HIGH or LOW
To output a signal that pretends to be Analog use this
code:
analogWrite ( pinNumber, value );
Where value is a number 0 - 255
Output
Output is always Digital
Using a Digital signal that pretends to be an Analog
signal is called Pulse Width Modulation
Use Pulse Width Modulation, or P.W.M., for anything
that requires a signal between HIGH and LOW
P.W.M. is available on Arduino pins # 3, 5, 6, 9, 10, and
11
Output
Output is always Digital, even when it’s P.W.M.
For P.W.M. the Arduino pin turns on then off very fast
P.W.M. Signal @ 75%
300
6
250
5
200
4
Voltage Value
PWM Value
P.W.M. Signal @ 25%
150
100
P.W.M. Signal rising
3
2
50
1
0
0
0
25
50
PWM Percentage
75
100
0
25
50
PWM Percentage
75
100
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, infared sensors, biometric sensors, or just
plain voltage from a circuit
Analog Input
• To connect an analog Input to your Arduino use
Analog Pins # 0 - 5
• To get an analog reading:
analogRead ( pinNumber );
• Analog Input varies from 0 to 1023 on an Arduino
Digital Input
• To connect digital input to your Arduino use Digital
Pins # 0 – 13 (Although pins # 0 & 1 are also used
for serial)
• Digital Input needs a pinMode command:
pinMode ( pinNumber, INPUT );
Make sure to use caps for INPUT
• To get a digital reading: digitalRead ( pinNumber );
• Digital Input values are only HIGH (On) or LOW (Off)
Digital Sensors
• 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
Setup, Internal Pullup Resistors
void setup ( ) {
digitalWrite (12, HIGH); }
You will need to create internal pullup resistors in setup,
to do so digitalWrite the pin HIGH
Serial Communication
Serial Communication is the
transferring and receiving of
information between two machines,
the Arduino dedicates pin # 0 to
receiving information and pin 1 to
transferring information
Serial in Setup
Serial Monitor
Serial Communication:
Serial Setup
void setup ( ) {
Serial.begin ( 9600 ) ;
}
In this case the number 9600 is the baud rate at
which the computer and Arduino communicate
Serial Communication:
Sending a Message
void loop ( ) {
Serial.print ( “Constructivism & “ ) ;
Serial.println ( “Mechatronics” ) ;
}
Serial Communication
Serial Communication:
Serial Debugging
void loop ( ) {
int xVar = 10 ;
Serial.print ( “Variable xVar is “ ) ;
Serial.println ( xVar ) ;
}
Serial Communication:
Serial Troubleshooting
void loop ( ) {
Serial.print ( “Digital pin 9 reads “ ) ;
Serial.println ( digitalRead ( 9 ) ) ;
}
Making the World’s Worst
Musical Instrument
Now for some really crappy dubstep….
If we have time.
Because, really, who has time for crappy
dubstep?
MODKit: WWW.modk.it
Graphical User Interface for intuitive coding of Arduino
Developed by Ed Baafi and Collin Reisdorf
Fritzing
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
Murphy’s Law
If it can go wrong, it will… eventually.
Be ready to improvise.
Developing Instructors
They will surprise you.
Being open will lead you to some interesting
places.
Have some student leaders.
Get some laughs to make people
comfortable.
Other Teaching Tools
Sewing:
http://www.sparkfun.com/tutorials/category/16
Processing:
http://processing.org/
Ohm’s Law Board:
http://learn.sparkfun.com/curriculum/26
Giant Breadboard and Components:
http://learn.sparkfun.com/curriculum/22,
http://learn.sparkfun.com/curriculum/23
Additional Resources:
http://learn.sparkfun.com/curriculum
http://www.arduino.cc/
Questions?
www.sparkfun.com
6175 Longbow Drive, Suite 200
Boulder, Colorado 80301