Basic Electronic Toolkit
for under $40
Multimeter http://www.mpja.com/prodinfo.asp?number=17191+TE Small Wire cutters http://www.mpja.com/prodinfo.asp?number=16761+TL Wire strippers http://www.mpja.com/prodinfo.asp?number=11715+TL Needle nose pliers http://www.mpja.com/prodinfo.asp?number=15395+TL Xacto knife Soldering iron and sponge http://www.mpja.com/prodinfo.asp?number=15860+TL Solder Solder sucker or desoldering braid http://www.mpja.com/prodinfo.asp?number=0041+TL Solderless Breadboard http://www.mpja.com/prodinfo.asp?number=18103+TE Assorted screw drivers Also useful: Small vise http://www.mpja.com/prodinfo.asp?number=17500+TL Hot melt glue gun miscellaneous pliers
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Sensor Safari Discussion
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Solenoid Valve (transducer) Doorbell (sensor)
Water
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Binary Sensors
i.e. switches
push button toggle key switch mercury tilt PIR motion
magnetic thermal humidity air pressure
Context is important
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Resistive Sensors
sense a range of values
Light level - photocell Position - flex sensors Tactile Pressure conductive foam Temperature - thermistor
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Advanced Sensors
accelerometers
distance - ultrasonic, IR capacitive proximity microphones GPS
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Arduino a small, stand-alone computer
Digital Inputs or Outputs
Power
Analog Inputs
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
ProtoShield
plugs into top of Arduino board
Assembly instructions for the other (Ladyada) version may be found at: http://www.ladyada.net/make/pshield/make.html
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Arduino Shields
Extend Arduino Capabilities
Example Shields: Xbee (wireless communications) Wave (audio playback, MP3) GPS & data logging Lithium Backpack (battery power) Motor Shield Button Shield Video (Atari quality)
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Arduino Programming Steps
Open an existing program or write a new one VERIFY checks Sketch (program) for mistakes UPLOAD copies program to Arduino board
Program can then run without PC Program restarts whenever Arduino power is applied or reset button is pressed Arduino can be powered by USB or external 7-12V supply
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Arduino Programming Elements
Comments: // or /* write stuff here */
Variables declared at beginning used to store numeric values or text Functions Setup (only executed once) Loop (main part of program, continuously repeated) Digital I/O Pins are general purpose, configure them in Setup
pinMode(PinNumber, OUTPUT);
Analog capable outputs (pins 9,10,11) should be set as outputs if needed Analog input pins (0-5) do not need to be configured
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Arduino Programming Notes
Every line has to end with a semicolon ; Curly Braces { } frame blocks of code Spelling and capitalization counts! digitalread(x) is not the same as digitalRead(x) Program text is color coded to help you spot mistakes Appendix C in Getting Started with Arduino summarizes commands and the Arduino program structure.
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Program Exercises
From Arduino Examples
Blink LED (binary output) Fade LED (analog output) binary input if { } else { }
Add switch to change fade rate (
Attach a photosensor (analog input) Adjust blink rate based on light level Send light level values to Mac using Serial.print FYI, example programs from the book can be found here:
http://makezine.com/getstartedarduino/ Copy and and paste them into an Arduino window, modify if desired, and then upload them to the board.
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Circuits for Binary Input
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Circuit for Binary Input
NOTE: Vdd = 5V Vss = GND
Whats a Microcontroller page 81
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Circuit for Resistive Sensor
Choose a resistor equal to about 1/3 of the sensors value
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Connecting a Photocell as a Sensor
any Arduino analog input
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Circuit for Analog Input from an Active Sensor
Active Sensor Requires Power Generates an analog signal Generally 0-5V output Example: distance sensors
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Sensors & Transducers <> Inputs & Outputs
Binary Input (Switch) Binary Output (on or off) Analog Input (resistive sensors) Analog Output (PWM)
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
More on Diodes
Resistors Follow Ohms law: V = IR Diodes DO NOT follow Ohms Law Diodes have a voltage drop across them (like a resistor) But diode voltage is (relatively) independent of current thru the diode
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Choosing a Resistor for an LED
LEDs have a characteristic voltage drop This Voltage is independent of current thru the LED Voltage varies based on LED type Voltage is in the range of 1.5 to 4V Desired current thru an LED is about 20mA Use Ohms law to find a resistance that will give you 20mA of current
Ohms Law: V=IR Vsupply VLED = (20mA) R Example:
5V 2V = 100 20mA
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Programming
Conditional: If { } else { } Loop: For { } Input and Output pinMode(pin#, input or output) digitalWrite(pin#, HIGH or LOW) digitalRead(pin#) analogWrite(pin#, 0-255) analogRead(pin#) Serial Communications Serial.begin(baud rate) Serial.println(number)
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio
Assignments
Build LED flasher kit Build protoshield
See earlier slide for example image of NKC electronics version Assembly instructions for the Ladyada version may be found at: http://www.ladyada.net/make/pshield/make.html
Read Chapter 5 and Appendix C in Getting Started with Arduino Extra Credit:
In class we worked with two Arduino programs, one (Blink) flashed an LED on and off every second, the other (Fading) made the brightness of an LED fade slowly in and out. Connect 2 LEDs to the Arduino and write a program (or modify the Blink or Fading program) to make one LED fade in and out and the other flash on and off.
Temple University
School of Communications and Theater
Physical Computing Spring 2010 Chris Vecchio