37
Making things sense Urban sensing and physical computing Day 2 (7-8 May 2011) Markus Rittenbruch QUT Urban Informatics / FAST & NICTA

Making things sense-Day 2 (May 2011)

Embed Size (px)

DESCRIPTION

Slides for the Edge Workshop

Citation preview

Page 1: 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

Page 2: Making things sense-Day 2 (May 2011)

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

Page 3: Making things sense-Day 2 (May 2011)

Making things sense - Day 2

Page 4: Making things sense-Day 2 (May 2011)

Programming

Page 5: Making things sense-Day 2 (May 2011)

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:

Page 6: Making things sense-Day 2 (May 2011)

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)

Page 7: Making things sense-Day 2 (May 2011)

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

Page 8: Making things sense-Day 2 (May 2011)

Analogue sensors

Page 9: Making things sense-Day 2 (May 2011)

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();

Page 10: Making things sense-Day 2 (May 2011)

Analogue sensor input

• File/Examples/Analog/AnalogInput

Page 11: Making things sense-Day 2 (May 2011)

Analogue sensor input

Page 12: Making things sense-Day 2 (May 2011)

Programming Conditionals

http://www.ladyada.net/learn/arduino/lesson5.html

Page 13: Making things sense-Day 2 (May 2011)

AnalogInput

Page 14: Making things sense-Day 2 (May 2011)

Calibration - part 1

Page 15: Making things sense-Day 2 (May 2011)

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

Page 16: Making things sense-Day 2 (May 2011)

Project activity 1 -Calibration

Page 17: Making things sense-Day 2 (May 2011)

Components

• RGB LED:

Page 18: Making things sense-Day 2 (May 2011)

Components• LED matrix

http://www.sparkfun.com/datasheets/Components/LED/YSM-1288CR3G2C.pdf

Page 19: Making things sense-Day 2 (May 2011)

Components• MAX7219 LED driver

http://arduino.cc/playground/Main/MAX72XXHardware

http://www.arduino.cc/playground/Main/LEDMatrix

Page 20: Making things sense-Day 2 (May 2011)

Project activity II -Projects

Page 21: Making things sense-Day 2 (May 2011)

So, you’ve got an Arduino and now you want to

make it talk

Page 22: Making things sense-Day 2 (May 2011)

Or, maybe you want to

talk to it...

Page 23: Making things sense-Day 2 (May 2011)

...from the other side of the world

Page 24: Making things sense-Day 2 (May 2011)

This session of the workshop will show you some ways of doing that.

Page 25: Making things sense-Day 2 (May 2011)

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

Page 26: Making things sense-Day 2 (May 2011)

Step 1: Register a feed on Pachube

Page 27: Making things sense-Day 2 (May 2011)
Page 28: Making things sense-Day 2 (May 2011)
Page 29: Making things sense-Day 2 (May 2011)

Step 2: Write some code

Page 30: Making things sense-Day 2 (May 2011)

Arduino Sketch

Page 31: Making things sense-Day 2 (May 2011)

Ruby “Bridge”: setup

Page 32: Making things sense-Day 2 (May 2011)

Ruby “Bridge”: the loop

Page 33: Making things sense-Day 2 (May 2011)

Step 3: See your data on Pachube

Page 34: Making things sense-Day 2 (May 2011)
Page 35: Making things sense-Day 2 (May 2011)

Advanced topics• PCB design

• Wireless communication

• Xbee

• Bluetooth

• Wifi

• Infrared

• Radio

• Real-time communication

• Multi-tasking

Page 36: Making things sense-Day 2 (May 2011)

Resources

• http://apiwiki.twitter.com/

• http://community.pachube.com/api

• http://community.pachube.com/tutorials

• http://community.pachube.com/triggers/twitter

Page 37: Making things sense-Day 2 (May 2011)

What next?• Hackerspace Brisbane

• http://hackerspaces.org/wiki/Hackerspace_Brisbane

• Living Dolls (The Edge)

• http://edgeqld.org.au/blog/2011/04/07/living-dolls/