Physical Computing �with Arduino
Lab meeting July 22, 2013
Molly Roberts
Carrington Lab, University of Washington Friday Harbor Labs
Arduino Components
Electronics Primer
LED
Photoresistor
Temperature sensor
Programming primer
Variables:
Int (integer) – No decimal places i.e. -1,0,1,2,3
Boolean – True or false
Float – Decimal places! ex. -3.402835*10^38
Char (character) – ex. a, b, c
Structure:
Void setup {…} – runs once
Void loop() {…} – runs again after it finishes
Programming primer
Digital (0 or 5V):
pinMode(pin #, Input or Output)
DigitalRead(pin #)
DigitalWrite (pin #, value)
Analog (between 0 and 5V):
int analogRead(pin)
int analogWrite(pin, value) (cheating a bit)
Don’t forget!
Fun!
LED
Getting started: Blinking LED
Simple circuit:
Power from Arduino
LED
Current-limiting resistor and Ground
Breadboarding
Arduino output: pin #13
Sketch setup
//Declare variable
Int ledPin = 13; //variable set to 13
//Run Once
Void setup ()
{
pinMode(ledPin, OUTPUT); //set pin mode to “OUTPUT” (not input)
}
Sketch
//Runs as a loop!
Void loop ()
{
digitalWrite(ledPin, HIGH); //Send 5V to LED
delay(1000); //Wait 1000ms
digitalWrite(ledPin, LOW); //Send 0V to LED
delay(1000); //Wait
}
Do it!
LED
Changing the code
Changing the code
For-loop review!
7 LEDs
Temp sensor
TMP 36 Gz
Solid state technique
Measure temperature across a diode
(As temp increases the voltage between the base and the emitter of a transistor increases)
Temp sensor
Serial.print(….)
Use a new function:
Temp sensor
Do it!
Temp and light sensor
Photoresistor
Changes resistance with light
ARDX arduino experimenter kit�
ARDX arduino experimenter kit�