week 02 - coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...thursday week 2: physical...

55
Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 1 Physical Computing Bridging the gap between the physical and virtual week 02

Upload: others

Post on 05-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

1

Physical ComputingBridging the gap between the physical and virtual

week

02

Page 2: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

2

How the Computer Sees Us

Shall we take a better look at ourselves to see our full range of expression?

Illustration from O’Sullivan and Igoe

Page 3: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

3

Physical Computing

A conversation between the physical world and the virtual world of the computer.

Page 4: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

4

Physical Computing

A conversation between the physical world and the virtual world of the computer.

TransductionThe conversion of one form of energy into another

Physical energy

Electric signals

Page 5: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

5

Input

Ways of sensing your physical energy/expressions. Input is usually easier than output because it takes less energy to sense activity than to move things.

Input and Output

Page 6: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

6

Output

Physical computing is not just about sensing the world, but also about changing it. But moving things are hard (you need electrical and mechanical skills).

Input and Output

Page 7: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

7

Transducers

output transducersActuators (e.g., motors, buzzers)

input transducerssensors (e.g., switches, levers, sliders, etc.)

Arduino

Illustration adapted and modified from O’Sullivan and Igoe

Page 8: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

8

Microcontrollers

Arduino

Illustration adapted and modified from O’Sullivan and Igoe

1) Receiving information from sensors, 2) controlling basic motors and other devices that create physical change, and 3) sending information to computers and other devices.

Gateway between the physical and the virtual

Page 9: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

9

Transduction

output transducers

input transducers

Arduino

Adapted and modified from O’Sullivan and Igoe

Your job is to find and learn to use transducers to convert between the physical energy appropriate for your project and the electrical energy used by the computer!

Page 10: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

10

Digital and Analog

Digital signal

Difference between two possible states

“whether or not”

Is the cat on the mat or not?

Analog signal

continuous range of possible states

“how much” or “stronger” “faster” “brighter”

How heavy is the cat that’s on the mat?

Page 11: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

11

Word of Caution: Your Idea is Important

1. Don’t get trapped in technological seduction

2. Don’t spin your wheels for so long that you give up your project. There might be an alternative way that makes things easier.

Work at a high level. Talk to us. Ask other people. Take frequent breaks.

From O’Sullivan and Igoe

Page 12: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

12

Working with ArduinoAn open-source electronics prototyping

Create interactive objects and environments

Page 13: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

13

What is Arduino

A tiny computer you can program, for rapid prototyping

Page 14: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

14

Arduino as an Interface Board

Illustration adapted and modified from O’Sullivan and Igoe

Arduino

Page 15: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

15

Arduino as an Interface Board

Illustration adapted and modified from O’Sullivan and Igoe

Arduino

Page 16: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

16

Arduino as an Embedded Computing Device

Illustration adapted and modified from O’Sullivan and Igoe

Arduino

Page 17: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

17

What is Arduino

Relatively cheap (compare with LEGO Mindstorm)

$250 ~$31

Page 18: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

18

What is Arduino

It used to be a bit more complicated…

image from www.tangentsoft.net/elec/breadboard.html

Page 19: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

19

Open source, so you can build one yourself!

Page 20: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

20

Arduino Board Overview

Page 21: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

21

Arduino Board Overview

• 16 kBytes of Flash program memory (your program stays in Arduino when powered off)

• 1 kByte of RAM

• 12 MHz (Apple II: 1 MHz) processor speed

Page 22: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

22

Arduino Board Overview

• 13 digital input/output pins

• 5 analog input pins

Page 23: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

23

Arduino Board Overview

Page 24: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

24

Arduino Board Overview

• USB to serial chip (converts simple serial signal to USB)

Page 25: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

25

Arduino Softwarewww.arduino.cc

Page 26: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

26

Arduino Software

Page 27: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

27

Arduino Sketches

Page 28: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

28

Arduino Programming Cycle

edit

upload

run verify

Page 29: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

29

Arduino Programming Cycle

edit

upload

run verify

Page 30: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

30

Arduino Programming Cycle

edit

upload

run verify

Page 31: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

31

Arduino Programming Cycle

edit

upload

run verify

1

2

Page 32: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

32

Arduino Programming Cycle

Watch your LED blink!

edit

upload

run verify

Page 33: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

33

Arduino Program

Program consists of 3 parts:

1. Declare variables at top

2. Initialize

setup() – run once at beginning, set pins

3. Run

loop() – run repeatedly, after setup()

Page 34: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

34

Arduino Language

Like C but easier

Example functions

• pinMode() – set a pin as input or output

• digitalWrite() – set a digital pin high/low

• digitalRead() – read a digital pin’s state

• analogRead() – read an analog pin

• analogWrite() – write an “analog” PWM value

• delay() – wait an amount of time

Page 35: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

35

Example (and many other examples at www.arduino.cc)

Page 36: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

36

Example (and many other examples at www.arduino.cc)

Declare variables

Page 37: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

37

Example (and many other examples at www.arduino.cc)

Initialize

Page 38: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

38

Example (and many other examples at www.arduino.cc)

Run

Page 39: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

39

Arduino and Breadboard

Page 40: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

40

Arduino and Breadboard

Page 41: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

41

Solderless Breadboard

Page 42: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

42

Solderless Breadboard

Page 43: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

43

Solderless Breadboard

Page 44: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

44

Circuits: Avoid Shortcuts

Electricity always favors the path of least resistance to ground

Illustration from O’Sullivan and Igoe

Page 45: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

45

Circuits: Avoid Shortcuts

Electricity always favors the path of least resistance to ground

Illustration from O’Sullivan and Igoe

Page 46: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

46

Circuits

All the electrical energy in a circuit must be used

Illustration from O’Sullivan and Igoe

Page 47: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

47

LED

• LED = Light-Emitting Diode

• Needs a “current limiting” resistor, or burns out

Illustration from Tod Kurt’s Spooky Projects

Page 48: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

48

Circuits Summary

Avoid deadly shortcuts

• Flows to the lowest resistance

• All the electrical energy in a circuit must be used

When in doubt, talk to us, we can help

(Your Arduino has some fail safe, but in the worst case, you could fry your board [$33.00])

Page 49: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

49

Try to be Neat

Color code:

• Red: power

• Black: ground

Be consistent

Good Bad

Page 50: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

50

Be Careful

Page 51: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

51

Lab Assignment This Week

• Get the course lab kit

• Download & install Arduino software (www.arduino.cc)

• Make an LED blink

• Make it blink at different rate

• Create your course web account

• Post the photo of your board and an optional comment on the course website

Page 52: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

52

Lab Assignment: Blinking LED

Resistorred, red, brown, gold

LED

Page 53: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

53

Your assignment looks like this

LED

Shorter leg groundPolarity matters

220 ohm resistorred, red, brown, goldPolarity does not matter

Page 54: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

54

Next Thursday

Don’t forget to bring your lab kit in

Do use the lab hour to catch up

Create your course account

Post your assignemtn on the course website

Page 55: week 02 - Coursescourses.ischool.berkeley.edu/i290-4/f08/slides/...Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces 8 Microcontrollers Arduino Illustration

Thursday Week 2: Physical Computing Theory and Practice of Tangible User Interfaces

55

Thanks!