Download presentation
Presentation is loading. Please wait.
Published byTrace Kimes Modified over 9 years ago
1
#10 Anne Roudaut hci2: building interactive devices hasso-plattner institute tangible & electronic
2
assignment design, prototype, and laser cut a robotic vehicle that you can control by projecting on it upload sketches, drawings, & photos to the wiki
3
design & built a motorized tangible object your task: shape allows users to pick up and move (onmi) wheels and motor, so it can move itself light sensors, to allow sending commands to the tangible
4
electronic part with an arduino board
5
and a set of components (battery / motors / photoresistors / chips / resistors …)
6
arduino
7
board
11
program on PC (simplified C++) upload to the board separate and run independently main advantage of Arduino!
12
processor usb plug (5V) external power (max 12v) some LEDs reset button pins when programming and testing to run independently
13
usb plug (5V) external power (max 12v) some LEDs reset button pins pins: to plug in components such as… processor
14
LEDs long leg is the + +-
15
pin “gnd” (ground)pin “12” (we will see later why we need the resistor) what’s happening? the LED blinks continuously
16
step by step
17
configure 0
18
pluging in 1 pin “gnd” (ground)pin “12”
20
e.g. all these pins are connected It is the same here etc. test board
21
compiling 2
22
uploading 3
23
it is blinking: the board is uploading the binary code (1 = light on / 0 = light off) 3
24
executing 1st loop 4
25
5 reseting executes setup ()
26
test 1 (5 mn) 1.plug in a resistor and an LED in pin 12 2.launch the File/Examples/Basic/Blink arduino files 3.modify the code to make the LED says “SOS” in Morse (3 shorts, 3 longs, 3 shorts) pin 12 (5 V) pin gnd Blue LED -+-+ blinking LED 82 ohm
27
don’t forget your programming skills! write functions
28
test 2 (5 mn) (with the same circuit) 1.upload File/Examples/Basic/Blink to the board 2.change the first delay value to 1 and the second to 1. upload the code to the board 3.change the first delay value to 1 and the second to 10. upload the code to the board 4.compare the three cases and tell me more! more blinking
29
1 2 3 blink bright less bright even less bright HIGH LOW delay(1) … delay(10) delay(1) … delay(1) delay(1000) … delay(1000)
30
1 2 3 HIGH LOW voltage is either 0 or 5v voltage is ½ of 5V voltage is a 1/11 of 5 V delay(1) … delay(10) delay(1) … delay(1) delay(1000) … delay(1000)
31
pulse width modulation :: technique using a rectangular pulse wave whose pulse width is modulated resulting in the variation of the average value of the waveform it serves to create an analog signal from a digital one
32
digitalWrite("pin number", HIGH or LOW) or analogWrite("pin number", "value in [0;255]") (% of voltage) there are special pins that produce PWM signals (in addition to digital signals)
33
test 3 (5 mn) 1.change your circuit to use a PMW pin 1.write code with analogWrite() to make the led smoothly blink (the brightness progressively increases) smooth blinking
34
pins are input and output
35
digitalWrite("pin number”,”HIGH or LOW”) digitalRead("pin number”) -> 1 or 0 (0 if voltage < 3v) digital pins are for input and output
36
analogWrite("pin number”,[0;255]) PWM pins are analog output
37
analogRead("pin number”) -> [0;1023] (1023 being the maximum voltage in the board) analog pins are for analog input
38
both digital and analog pins deal with voltages reading input works with every components that generate voltages
39
battery
40
pin “gnd” pin “A0” 1.5V battery on A0 pin to read it voltage by the way, components that generate high voltage will damage the board, be careful!
41
digitalWrite(A0,HIGH)
42
Monitor display Serial.print() Serial,println() 305 305 of [0;1023] so 305x5/1023 = 1,49V
43
so it works with components that generate voltages such as…
44
photodiode voltage increases when the intensity of light increases
45
piezoelectric cells voltage increases when pressure increases
46
but also with components that generate resistance (and we will see the trick later)
47
conductive foam material in what components are plug in it removes electrostatic charges
48
conductive foam the more you squeeze it, the less it resists to the travel of the charges it lets the charge passing thought: it conduces charges
49
pin “gnd” pin “A0” let’s play with a piece of conductive foam
50
test 4 (5 mn) 1.plug in two wires and a piece of foam between pin A0 and GND 1.write code to display the change of voltage on pin A0 1.write code to make an LED more or less bright when you squeeze the foam read pins
53
it is a simple way to make a pressure sensor
55
at this point you know the basics of arduino you are almost ready to go what remains now is some math in order to understand…
56
why do we need a resistor with the LED? how does an input pin read different values of resistance whereas we said it reads voltage? 1 2
57
let’s forget arduino for a moment
58
-+-+ 3 electric quantities voltage / current / resistance battery resistor
59
-+-+ voltage is the amount of cars it is measured in Volt battery resistor traffic jam analogy
60
resistance defines the type of road it is measured in Ohm (Ω) 10 Kilo OHM vs. 60 OHM vs highways let more cars passing through current is the amount of cars that pass through the circuit per units of time (the flow) it is measured in Ampere
61
Current Voltage plumbing analogy
62
the smaller the road is (resistance increases), the slower the flow of cars is (current decreases) the harder a pipe is pressed, the smaller the water flow is
63
the relation between these 3 quantities is given by Ohm’s law U = R x I Volt Ohm Ω Ampere
64
U=RI works for resistors Current (I) 1 Ω resistor
65
resistors color code = value
66
more generally, U=RI works for ohmic materials Current (I) 1 Ω resistor Voltage (U) 1 meter silver (1.59×10 −8 Ω) 1 meter air (1.3×10 16 Ω) 1 meter sea water (0.2 Ω) conductors insulators
67
most components are not ohmic e.g. light bulb / LED / motor
68
ligh bulb U I the resistance of the filament increases with its temperature
69
LED works in a small interval of voltage steep slope: small variations of voltage = large variations of current U I
70
U I LED offLED on (brightness increasing) LED blows max current indicated on the spec working voltage interval indicated on the spec
72
to reduce current we put a resistor in serie to know it value, we use Ohm’s law Red LED [1.8;2.2] V 0,02 A -+-+ (5-2.2) = R x 0,02 R = 140Ω -+-+ 5 V battery
73
we can also adapt the voltage but … Red LED [1.8;2.2] V 0,02 A -+-+ 2 V battery -+-+
74
U I LED offLED on (brightness increasing) LED blows steep slope: when the voltage decreases a little bit, the current dramatically decreases, thus decreasing the brightness
75
the resistor also regulates the LED voltage, that stays almost constant Red LED [1.8;2.2] V 0,02 A -+-+ -+-+ 5V battery 140Ω
76
so LEDs must always be mounted with a resistor in serie
77
-+-+ -+-+ true for several LEDs in serie -+-+ 5V battery Red LEDs [1.8;2.2] V 0,02 A (5-2x2.2) = R x 0,02 R = 30Ω 30Ω
78
-+-+ -+-+ true for several LEDs in parrallel -+-+ 5V battery Red LEDs [1.8;2.2] V 0,02 A (5-2.2) = R x 0,02 R = 140Ω 140Ω (voltage is the same in each branch)
79
-+-+ -+-+ if LEDs are the same, we can also serialize the resistor -+-+ 5V battery Red LEDs [1.8;2.2] V 0,02 A (5-2.2) = R x (2x0,02) R = 70Ω 70Ω 0.04 A is drained from the battery (current splits in each branch)
80
why do we need a resistor with the LED? how does an input pin read different values of resistance whereas we said it reads voltage? 1 2 done and we know how to compute it value
81
squeezing the foam changes the resistance but the voltage of A0 pin was changing
82
Battery 5 V conductive foam -+-+ the resistance changes and thus the current (Ohm’s law) but still not the voltage
83
so there must be a trick somewhere … we must use a tension divider circuit layout
84
tension divider R foam + R pullup R foam x V in V out = V in -+-+ pull-up resistor V out
85
V in -+-+ V out demonstration V in = R pullup I + R foam I (1)ohm’s law U = RI (2) Kirchhoff 2 nd law Σ voltage drop by components = Σ voltage generates in the circuit by the way, Kirchhoff 1 st law at any nodes, Σ current floating in = Σ current floating out
86
V in -+-+ V out demonstration V in = R pullup I + R foam I (1)ohm’s law U = RI (2) Kirchhoff 2 nd law Σ voltage drop by components = Σ voltage generates in the circuit V out = R foam I V out = R foam x V in (R pullup + R foam ) So
87
pin 5V R foam + R pullup R foam X 5 A0 = so the arduino circuit can look like that e.g. 10 KΩ (to have precise A0 value) pull-up resistor pin A0 pin GND
88
pin 5V pull-up resistor pin A0 pin GND but arduino also have an internal pull-up resistor -> we can plug in the foam between A0 and gnd Optional if internal pull up resistor is enabled
89
potentiometer by the way, a potentiometer is a tension divider circuit Vout Vingndresistor adjustable
90
why do we need a resistor with the LED? how does an input pin read different values of resistance whereas we said it reads voltage? 1 2 done and we know how to compute it value
91
use multimeter (in the shop) to check voltage: in parrallel current: in serie
92
more components
93
motor M
94
photoresistor resistance decreases when the intensity of light increases
95
relays to switch on higher voltage
96
transistors a small current at the Base can control or switch a much larger current between the Collector and Emitter It serves as a switch or current amplifier
97
capacitors they store electric charge
98
capacitors
99
chips or integrated circuits (the notch shows the orientation when reading the spec) more pins!
100
chips 7400 serie = 4 NAND GATES A B out 001 011 101 110 A B out example:
101
Gleichrichter chips H-BRIDGE It can inverse the polarity of two motors (one on each side) It doesn't control the amount of voltage (i.e. the speed). For that, you must reduce or increase the voltage sent on pin 8
102
chips H-BRIDGE
103
chips H-BRIDGE Pin 8 is the power for the chip. It has to be max 5V. Just plug in it to a digital pin always HIGH Pin 6 is the control pin for the left motor. If it is HIGH the left motor do something, otherwise nothing (same principle for the pin 7 controlling the motor on the right) If pin 2 LOW pin 3 HIGH, then the left motor will turn in one direction If pin 2 HIGH pin 3 LOW, the left motor will turn in the other direction If both pin 2 and 3 have the same value the left motor stop (same principle for right motor and pin 4 and 5)
104
555 timer (e.g. toaster timer) 741 operational amplifier (amplify current) Accelerometers … chips etc.
105
without the computer
106
external power max 12 V (some versions can handle more) max 40mA per pins max 50mA on 3.3V pin
107
for your 9V battery
109
assignment design, prototype, and laser cut a robotic vehicle that you can control by projecting on it upload sketches, drawings, & photos to the wiki Go! be sure your design is feasible : - check materials before - ask Professor or TA
110
end
111
have you ever tasted a 9V battery? no more than 9V!
112
try different flavors ! wetdry
113
Ampere (current/flow) (A) Resistance (Ohm Ω) Voltage (pressure) (V) Water level
114
= electron particle
115
different flavors = different resistance electrons flow more or less easily wetdry
116
encoder
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.