Making things sense-Day 2 (May 2011)
-
Upload
markumoto -
Category
Technology
-
view
1.041 -
download
1
description
Transcript of Making things sense-Day 2 (May 2011)
Making things senseUrban sensing and physical computing
Day 2 (7-8 May 2011)
Markus RittenbruchQUT Urban Informatics / FAST & NICTA
Schedule - Day 2
• 12:00 - 12:10 Introduction
• 12:10 - 12:30 Analogue sensors
• 12:30 - 13:00 Activity
• 13:00 - 14:00 Sharing sensor data
• 14:00 - 14:10 Short break
• 14:10 - 16:10 Project activity
• 16:10 - 16:50 Project presentations
• 16:50 - 17:00 Wrap up
Making things sense - Day 2
Programming
ProgrammingData types
When variables are made to exceed their maximum capacity they "roll over" back to their minimum capacity, note that this happens in both
directions.
int x
x = -32,768;
x = x - 1; // x now contains 32,767 - rolls over in neg. direction
x = 32,767;
x = x + 1; // x now contains -32,768 - rolls over
Float & casting:
ProgrammingFloat & casting:
int x; int y; float z;
x = 1; y = x / 2; // y now contains 0, ints can't hold fractions z = (float)x / 2.0; // z now contains .5 (you have to use 2.0, not 2)
Resources• Language reference:
• http://www.arduino.cc/en/Reference/HomePage
• http://arduino.cc/en/Reference/Extended
• General code library:
• http://arduino.cc/en/Reference/Libraries
• Interfacing with hardware:
• http://www.arduino.cc/playground/Main/InterfacingWithHardware
• Examples
• http://arduino.cc/en/Tutorial/HomePage
Analogue sensors
Analogue sensor pins
• Use analogue in pins 0-5 for analogRead()
• Address as 14-19 when used as digital pins
• digitalWrite(), digitalRead()
• No pinMode required for analogRead();
Analogue sensor input
• File/Examples/Analog/AnalogInput
Analogue sensor input
Programming Conditionals
http://www.ladyada.net/learn/arduino/lesson5.html
AnalogInput
Calibration - part 1
Calibration - part 2
• map(): remap a number from one range to another
• val = map(val, 0, 1023, 0, 255);
• constrain(): constrain to a number range
Project activity 1 -Calibration
Components
• RGB LED:
Components• LED matrix
http://www.sparkfun.com/datasheets/Components/LED/YSM-1288CR3G2C.pdf
Components• MAX7219 LED driver
http://arduino.cc/playground/Main/MAX72XXHardware
http://www.arduino.cc/playground/Main/LEDMatrix
Project activity II -Projects
So, you’ve got an Arduino and now you want to
make it talk
Or, maybe you want to
talk to it...
...from the other side of the world
This session of the workshop will show you some ways of doing that.
Arduino to the world
• Arduino direct to Pachube via ethernet/wifi shield
• Or Arduino to PC via serial, then to Pachube/Twitter
• We’re taking the second approach in this workshop, since the kits we provided don’t include ethernet/wifi shields
Step 1: Register a feed on Pachube
Step 2: Write some code
Arduino Sketch
Ruby “Bridge”: setup
Ruby “Bridge”: the loop
Step 3: See your data on Pachube
Advanced topics• PCB design
• Wireless communication
• Xbee
• Bluetooth
• Wifi
• Infrared
• Radio
• Real-time communication
• Multi-tasking
Resources
• http://apiwiki.twitter.com/
• http://community.pachube.com/api
• http://community.pachube.com/tutorials
• http://community.pachube.com/triggers/twitter
What next?• Hackerspace Brisbane
• http://hackerspaces.org/wiki/Hackerspace_Brisbane
• Living Dolls (The Edge)
• http://edgeqld.org.au/blog/2011/04/07/living-dolls/