Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started...
Transcript of Physical Computing - Keio UniversityLab, ty Physical Computing • Massimo Banzi, “Getting Started...
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
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!
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
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
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
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
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
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
+ - + -
Independent Power Lines
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
VIN GND
+ - + -
+
-
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
VIN GND
+ - + -
+
-
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
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
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
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
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
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
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
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
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Check Points: Libraries
• TimeOne Library
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Check Points: Board Selection
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Check Points: Serial Port
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Check Points: Serial Port on Windows
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?
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Program Arduino
• Change the blink rate and upload again
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
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
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
AnalogInput
• http://arduino.cc/en/Tutorial/AnalogInput
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
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.
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Serial Communication with ARTK
• User ComPort Library with ARToolKit.
• Serial.h
• SerialSample.cpp
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.
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
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
Su
gim
oto
Lab,
Kei
o U
niv
ersi
ty
Photo-transistor
• Photo-diode + transistor
• Current output according to brightness
写真:新光電子株式会社Webから引用
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
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