Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started...

36
Sugimoto Lab, Keio University Physical Computing Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 Tom Igoe, “Making Things Talk”, Make Books, 2007

Transcript of Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started...

Page 1: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Physical Computing

• Massimo Banzi, “Getting Started

With Arduino”, Make Books, 2008

• Tom Igoe, “Making Things Talk”,

Make Books, 2007

Page 2: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Arduino

• Open Platform

• CPU: ATMEL AVR

• Arduino IDE

• http://arduino.cc/en/Main/Software

• Let’s install the IDE!

Page 3: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

• Prototyping Toolkit

• No Soldering

• Pros.

– Easy to use

– Testing with real components

– Re-usable

• Cons.

– Not good for mass-scale development

– Unstable

– Impossible to use high frequencies

– Larger footprint / space consumption

Breadboard

Page 4: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Process of Developments

アプリケーション

Idea Sketch

Block Diagram

Printed Circuit Board

Breadboard Prototype

Requirements

Testing

Starting Point

Page 5: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Parts List

• Breadboard

• Micro-Controller Unit (MCU) PIC

• 0.1uF Capacitor

• Battery Box + Battery

• LED (Blue,Green)

• Resistor(2.2kΩ) x 2

• Speaker

• Switch

• Variable Resistor(5kΩ, 1MΩ)

• Phototransistor

• Accelerometer

Page 6: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Page 7: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Memo

• Parts which looks alike

– Blue LED (wide foot)

– Green LED

– Phototransistor (normal foot)

• Colors of the jumper wires does not have a

functional meaning

– But, there are some formal rules

– Brighter : Higher Voltage

– Darker : Lower Voltage

Page 8: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

+ - + -

Independent Power Lines

Page 9: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

+

-

Page 10: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

+

-

Page 11: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Sequence

• Stage1

1. Green LED

• For blinking application

2. Upload firmware to Arduino

3. Change the blink rate in code

• Stage2

– Variable Resistor

– Buzzer

• Stage3

– Accelerometer

Page 12: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+

-

+ - + -

10

11

12

13

A0 A

1 A

2 A

3 V

CC

RST

GN

D R

AW

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

Page 13: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Power Line for MCU

8

D 2

7

D 3

6

D 4

5

D 5

4

D 6

3

D 7

2

D 8

1

D 9

9

G N D

1 0

RESET

1 1

R X I

1 2

T X O

JP7

1

R A W

2

G N D

3

RESET

4

V C C

5

A 3

6

A 2

7

A 1

8

A 0

9

SCK

1 0

MISO

1 1

MOSI

1 2

D10

JP6

Page 14: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

10

11

12

13

A0

A1

A2

A3

VC

C R

ST G

ND

RA

W

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

Page 15: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

10

11

12

13

A0

A1

A2

A3

VC

C R

ST G

ND

RA

W

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

Page 16: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Blink LED (Green)

+ - Pin Assignment

8

D 2

7

D 3

6

D 4

5

D 5

4

D 6

3

D 7

2

D 8

1

D 9

9

G N D

1 0

RESET

1 1

R X I

1 2

T X O

JP7

1

R A W

2

G N D

3

RESET

4

V C C

5

A 3

6

A 2

7

A 1

8

A 0

9

SCK

1 0

MISO

1 1

MOSI

1 2

D10

JP6

2.2k

L E D 1

G N D

Page 17: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

10

11

12

13

A0

A1

A2

A3

VC

C R

ST G

ND

RA

W

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

+

-

+ - Pin Assignment

LED

Page 18: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Program Arduino

• Compile and upload the code named

“Blink”

• http://arduino.cc/en/Tutorial/Blink

Page 19: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Check Points: Libraries

• TimeOne Library

Page 20: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Check Points: Board Selection

Page 21: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Check Points: Serial Port

Page 22: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Check Points: Serial Port on Windows

Page 23: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Check Points

• Caution

– Mind the polarity of LED

• Be careful when turning on the power for first

time

– You can check it by your five senses

• Hotness, smell, sound … et

• Blink LED: Blinking?

Page 24: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Program Arduino

• Change the blink rate and upload again

Page 25: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Variable Resistor

Analog Port

+ -

R R

8

D 2

7

D 3

6

D 4

5

D 5

4

D 6

3

D 7

2

D 8

1

D 9

9

G N D

1 0

RESET

1 1

R X I

1 2

T X O

JP7

1

R A W

2

G N D

3

RESET

4

V C C

5

A 3

6

A 2

7

A 1

8

A 0

9

SCK

1 0

MISO

1 1

MOSI

1 2

D10

JP6

2.2k

L E D 1

G N D

Page 26: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

10

11

12

13

A0

A1

A2

A3

VC

C R

ST G

ND

RA

W

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

+

-

Variable Resistor

Page 27: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

AnalogInput

• http://arduino.cc/en/Tutorial/AnalogInput

Page 28: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Analog Interfaces of MCUs

• Input

– AD (Analog to Digital) Convert

• Sampling and Quantization

• Nyquist–Shannon sampling theorem

• Output

– DA (Digital to Analog) Convert

• Inverse of ADC process

• Analog voltage output

– PWM (Pulse Width Modulation)

• The modulation of duty cycle

• High frequency on / off control

Page 29: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Serial Communication

• Write AnalogReadSerial example.

http://arduino.cc/en/Tutorial/AnalogReadS

erial

• Execute Serial Monitor.

Page 30: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Serial Communication with ARTK

• User ComPort Library with ARToolKit.

• Serial.h

• SerialSample.cpp

Page 31: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Accelerometer

• measures acceleration and gravity induced

reaction forces.

• is based on inside capacitances of IC packages.

Page 32: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Accelerometer

8

D 2

7

D 3

6

D 4

5

D 5

4

D 6

3

D 7

2

D 8

1

D 9

9

G N D

1 0

RESET

1 1

R X I

1 2

T X O

JP7

1

R A W

2

G N D

3

RESET

4

V C C

5

A 3

6

A 2

7

A 1

8

A 0

9

SCK

1 0

MISO

1 1

MOSI

1 2

D10

JP6

Page 33: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN

GND

+ - + -

10

11

12

13

A0

A1

A2

A3

VC

C R

ST G

ND

RA

W

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

+

-

+

-

1 8

Page 34: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Photo-transistor

• Photo-diode + transistor

• Current output according to brightness

写真:新光電子株式会社Webから引用

Page 35: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

Phototransistor

8

D 2

7

D 3

6

D 4

5

D 5

4

D 6

3

D 7

2

D 8

1

D 9

9

G N D

1 0

RESET

1 1

R X I

1 2

T X O

JP7

1

R A W

2

G N D

3

RESET

4

V C C

5

A 3

6

A 2

7

A 1

8

A 0

9

SCK

1 0

MISO

1 1

MOSI

1 2

D10

JP6

Page 36: Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started With Arduino”, Make Books, 2008 • Tom Igoe, “Making Things Talk”, Make

Su

gim

oto

Lab,

Kei

o U

niv

ersi

ty

VIN GND

+ - + -

10

11

12

13

A0

A1

A2 A

3 V

CC

RST

GN

D R

AW

9 8

7 6

5 4

3 2

GN

D R

ST R

XI T

XO

GND VCC RXI TXO BLK

GR

N

+

-

+

-

Variable

Resistor

+ - Pin Assignment

Vdd

GND

R

Analog

Output

Phototransistor