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

Making things sense - Day 1 (May 2011)

Embed Size (px)

DESCRIPTION

Slides for Edge workshop

Citation preview

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

Making things senseUrban sensing and physical computing

Day 1 (7-8 May 2011)

Markus RittenbruchQUT Urban Informatics / FAST & NICTA

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

Schedule - Day 1

• 12:00 - 12:20 Introduction

• 12:20 - 13:30 Getting started

• 13:30 - 13:45 Short Break

• 13:45 - 14:15 Basic electronics

• 14:15 - 15:00 Arduino in detail

• 15:00 - 15:30 Coffee break (Lumia)

• 15:30 - 15:50 Introduction Activity

• 15:50 - 16:50 Activity

Page 3: Making things sense - Day 1 (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 4: Making things sense - Day 1 (May 2011)

Making things sense - Day 1

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

Examples

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

http://www.tangibleinteraction.com

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

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

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

http://diydrones.com/profiles/blog/show?id=705844%3ABlogPost%3A44817

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

http://www.slq.qld.gov.au/whats-on/lumia

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

Books

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

Slides

http://www.slideshare.net/markumoto

http://www.slideshare.net/markumoto

Day 1

Day 2

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

Getting started

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

Physical computing

• Transduction

• Transforming energy

• Digital and analog

• Parallel and serial

• Stages of input, output and processing

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

Overview• Workshop hardware components

• Parts:

• Physical computing

• Arduino board

• Arduino code

• Arduino IDE

• Writing a program

• Download and install Arduino

• Arduino Hello World / Blink

• Tutorials: http://www.ladyada.net/learn/arduino/index.html

http://www.littlebirdelectronics.com/ http://toysdownunder.com/

http://www.sparkfun.com/commerce/tutorials.php

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

Arduino starter kit

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

Arduino overview

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

The boards can be built by hand or purchased preassembled; the software can be downloaded for free. The hardware reference designs (CAD files) are available under an open-source license, you are free to adapt them to your needs.

(Atmega8U2)

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

Arduino specification• Arduino Uno (2011)

• Microcontroller ATmega328

• Operating Voltage 5V

• Input Voltage (recommended) 7-12V

• Input Voltage (limits) 6-20V

• Digital I/O Pins 14

• Analog Input Pins 6

• DC Current per I/O Pin 40 mA

• DC Current for 3.3V Pin 50 mA

• Flash Memory 32 KB of which 0.5 KB used by bootloader

• SRAM 2 KB

• EEPROM 1 KB

• Clock Speed 16 MHz

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

Other platforms

I-CubeX

Phidgets

Wiring

Stamp

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

Arduino code

• Code in a C-like high-level language (Wiring)

• Inbuilt functions to read and set digital and analog inputs and outputs

• Includes libraries to perform common hardware or software tasks

• Sketches

• Many language bindings:

• Flash & Flex, Processing, Python, Ruby, Java,C. C++, Objective-C, .NET

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

Arduino IDE

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

Blink code

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

Breadboards

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

Breadboard basics

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

Blink circuit

Schematic

Connections

LED: Anode / Cathode

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

Arduino IDE install

• Install Arduino 22 (http://www.arduino.cc/en/Guide/HomePage)

• (Install USB driver)

• Select serial port

• Select board

• Examples: Blink

• Compile and upload process

• Write to Serialport

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

Blink modifications

1. Talk to the serial console

2. Experiment with intervals

3. Change pins

4. Try this!

Page 27: Making things sense - Day 1 (May 2011)

Well done! Take a break.

Page 28: Making things sense - Day 1 (May 2011)

Basic electronics

Page 29: Making things sense - Day 1 (May 2011)

Basic electronics• Water analogy

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

Basic electronics• Current, Voltage and Power

• Voltage is measured in Volts (V) → V

• Current is measured in Amperes (A) → I

• Power is measured in Watts (W) → P

• Power = Current x Voltage (P = I x V)

• Arduino

• 5V (or 3.3V)

• 40mA (0.04A) output pin

• Direct current (DC) and alternating current (AC)

• Mains is nasty!

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

Basic electronics• Electricity flow

• Path of least resistance

• All electrical energy must be used

• Basic electrical circuit

• Components in series

• Same current, decreasing voltage

• Components in parallel

• Different current, same voltage

• Short circuit

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

Basic electronics

• Schematic / Circuit diagram

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

Basic electronics

• Resistor

• Conductors, insulators and resistance

• Resist the flow of electricity (current)

• Precise control of electrical current

• Measured in Ohm (1Ω - 1MΩ)

• Symbol

• Colour-code

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

Basic electronics

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

Basic electronics• Types of resistors

• Thermistor

• Photocell (LDR)

• Potentiometer (trim pot, variable resistor)

• Force sensitive resistor (FSR)

• Flex sensor

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

Basic electronics

• Resistor and resistance

• Resistors in series

• R = R1 + R2

• Resistors in parallel

• R = R1 x R2 / (R1 + R2)

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

Basic electronics

• Diodes and LEDs

• Diodes are polarised

• Electricity flows in one direction

• Anode (+), Cathode (-)

• LED (Light-emitting diode)

Page 38: Making things sense - Day 1 (May 2011)

Basic electronics• Ohm’s law and current limiting

V

I R

Ohm’s triangle

R = V / II = V / RV = I x R

• Data sheets are your friend!

Page 39: Making things sense - Day 1 (May 2011)

Adjusting brightness

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

Page 40: Making things sense - Day 1 (May 2011)

Basic electronics

• Capacitor

• Store electricity

• Farad (F) (mF or μF, pF, nF)

• Polarised , unpolarised

• Ceramic, tantalum, electrolytic

• Common sizes:

• 22pF / 0.01μF / 0.1μF ceramic

• 1μF / 10μF electrolytic

Page 41: Making things sense - Day 1 (May 2011)

Basic electronics

• Capacitors

• Capacitors in series

• C = C1 x C2 / (C1 + C2)

• Capacitors in parallel

• C = C1 + C2

Page 42: Making things sense - Day 1 (May 2011)

The Arduino in detail

Page 43: Making things sense - Day 1 (May 2011)

Overview• Digital pins

• Pull-up and pull-down resistors

• Analogue input pins

• Pulse with modulation (PWM)

• Other

• ICSP

• Interrupts

• I2C communication

• Analogue reference

Page 44: Making things sense - Day 1 (May 2011)

Digital pins• Pins 0-13 (GPIO pins)

• Either input our output (default to input)

• Can output 40 mA

• pinMode

• digitalWrite

Page 45: Making things sense - Day 1 (May 2011)

Digital pins• digitalRead (http://www.ladyada.net/learn/arduino/

lesson5.html)

Page 46: Making things sense - Day 1 (May 2011)

Digital pins• digitalRead

/* * Switch test program */int switchPin = 2; // Switch connected to digital pin 2

void setup() // run once, when the sketch starts{ Serial.begin(9600); // set up Serial library at 9600 bps pinMode(switchPin, INPUT); // sets the digital pin as input to read switch}

void loop() // run over and over again{ Serial.print("Read switch input: "); Serial.println(digitalRead(switchPin)); // Read the pin and display the value delay(100);}

Page 47: Making things sense - Day 1 (May 2011)

Digital pins• Switching

Page 48: Making things sense - Day 1 (May 2011)

Digital pins• Pull-up and pull-down resistors

Pull-down

Pull-up

Page 49: Making things sense - Day 1 (May 2011)

Digital pins• Arduino schematic / Reset

Page 50: Making things sense - Day 1 (May 2011)

Digital pins• What happens if we digitalRead a pin that is not connected?

• 20K internal pull-up resistor

• Serial pins 0 (RX) and 1 (TX). Connected to FTDI USB-to-TTL

• Pin 13 is different (input) (RES + LED)

• Analogue pins A0-A5 can be used as digital pins 14-19 (GPIO)

• Read up to 5V. Don’t fry your pin!

Page 51: Making things sense - Day 1 (May 2011)

Analogue input pins• Pins A0-A5

• 6 channel analog-to-digital (A/D) converter

• 10 bit resolution (from 0-5V to int 0-1023)

• 100 microseconds (0.0001 s) to read an analog input, maximum reading rate is about 10,000 times a second.

• Pull-up resistor same as digital pins

• Unexpected readings?

• Has pin been set to input?

• Check pull-up resistor [digitalWrite(A0, HIGH); ]?

Page 52: Making things sense - Day 1 (May 2011)

Analogue input pins• AnalogRead (use A1 instead of 1)

Page 53: Making things sense - Day 1 (May 2011)

Pulse with modulation• PWM used to create analogue output on digital pins

• Simulate voltage between 5V and 0V using square waves (signal switching between on and off)

• Pins 3, 5, 6, 9, 10, and 11

Page 54: Making things sense - Day 1 (May 2011)

• AnalogWrite

Page 55: Making things sense - Day 1 (May 2011)

Other pins• ICSP (In Circuit Serial Programming) directly

program AVR micro-controllers

• I2C / TWI (Two-wire interface) communication

• Inter IC control

• Arduino analog input A4 = I2C SDA (serial data line)

• Arduino analog input A5 = I2C SCL (serial clock line)

• External interrupts

• Event-handling without polling

• Interrupt 0 (on digital pin 2) and 1 (on digital pin 3)

• Analogue reference

• Set analogue reference for ADC

Page 56: Making things sense - Day 1 (May 2011)

Coffee break

Page 57: Making things sense - Day 1 (May 2011)

Activity

Page 58: Making things sense - Day 1 (May 2011)

Activity overview• Pair up

• Use a switch & LED

• Use a poti & LED

• Design challenges: http://www.ladyada.net/learn/arduino/lesson5.html

• Draw a circuit diagram

• Fade 2 LEDs

• Use multicolour LED

• http://www.arduino.cc/en/Reference/HomePage

• [Use your digital temperature sensor]