#10 Anne Roudaut hci2: building interactive devices hasso-plattner institute tangible & electronic
assignment design, prototype, and laser cut a robotic vehicle that you can control by projecting on it upload sketches, drawings, & photos to the wiki
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
electronic part with an arduino board
and a set of components (battery / motors / photoresistors / chips / resistors …)
arduino
board
program on PC (simplified C++) upload to the board separate and run independently main advantage of Arduino!
processor usb plug (5V) external power (max 12v) some LEDs reset button pins when programming and testing to run independently
usb plug (5V) external power (max 12v) some LEDs reset button pins pins: to plug in components such as… processor
LEDs long leg is the + +-
pin “gnd” (ground)pin “12” (we will see later why we need the resistor) what’s happening? the LED blinks continuously
step by step
configure 0
pluging in 1 pin “gnd” (ground)pin “12”
e.g. all these pins are connected It is the same here etc. test board
compiling 2
uploading 3
it is blinking: the board is uploading the binary code (1 = light on / 0 = light off) 3
executing 1st loop 4
5 reseting executes setup ()
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
don’t forget your programming skills! write functions
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
1 2 3 blink bright less bright even less bright HIGH LOW delay(1) … delay(10) delay(1) … delay(1) delay(1000) … delay(1000)
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)
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
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)
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
pins are input and output
digitalWrite("pin number”,”HIGH or LOW”) digitalRead("pin number”) -> 1 or 0 (0 if voltage < 3v) digital pins are for input and output
analogWrite("pin number”,[0;255]) PWM pins are analog output
analogRead("pin number”) -> [0;1023] (1023 being the maximum voltage in the board) analog pins are for analog input
both digital and analog pins deal with voltages reading input works with every components that generate voltages
battery
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!
digitalWrite(A0,HIGH)
Monitor display Serial.print() Serial,println() of [0;1023] so 305x5/1023 = 1,49V
so it works with components that generate voltages such as…
photodiode voltage increases when the intensity of light increases
piezoelectric cells voltage increases when pressure increases
but also with components that generate resistance (and we will see the trick later)
conductive foam material in what components are plug in it removes electrostatic charges
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
pin “gnd” pin “A0” let’s play with a piece of conductive foam
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
it is a simple way to make a pressure sensor
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…
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
let’s forget arduino for a moment
electric quantities voltage / current / resistance battery resistor
-+-+ voltage is the amount of cars it is measured in Volt battery resistor traffic jam analogy
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
Current Voltage plumbing analogy
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
the relation between these 3 quantities is given by Ohm’s law U = R x I Volt Ohm Ω Ampere
U=RI works for resistors Current (I) 1 Ω resistor
resistors color code = value
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
most components are not ohmic e.g. light bulb / LED / motor
ligh bulb U I the resistance of the filament increases with its temperature
LED works in a small interval of voltage steep slope: small variations of voltage = large variations of current U I
U I LED offLED on (brightness increasing) LED blows max current indicated on the spec working voltage interval indicated on the spec
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Ω V battery
we can also adapt the voltage but … Red LED [1.8;2.2] V 0,02 A V battery -+-+
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
the resistor also regulates the LED voltage, that stays almost constant Red LED [1.8;2.2] V 0,02 A V battery 140Ω
so LEDs must always be mounted with a resistor in serie
true for several LEDs in serie V battery Red LEDs [1.8;2.2] V 0,02 A (5-2x2.2) = R x 0,02 R = 30Ω 30Ω
true for several LEDs in parrallel V 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)
if LEDs are the same, we can also serialize the resistor V 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)
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
squeezing the foam changes the resistance but the voltage of A0 pin was changing
Battery 5 V conductive foam -+-+ the resistance changes and thus the current (Ohm’s law) but still not the voltage
so there must be a trick somewhere … we must use a tension divider circuit layout
tension divider R foam + R pullup R foam x V in V out = V in -+-+ pull-up resistor V out
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
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
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
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
potentiometer by the way, a potentiometer is a tension divider circuit Vout Vingndresistor adjustable
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
use multimeter (in the shop) to check voltage: in parrallel current: in serie
more components
motor M
photoresistor resistance decreases when the intensity of light increases
relays to switch on higher voltage
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
capacitors they store electric charge
capacitors
chips or integrated circuits (the notch shows the orientation when reading the spec) more pins!
chips 7400 serie = 4 NAND GATES A B out A B out example:
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
chips H-BRIDGE
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)
555 timer (e.g. toaster timer) 741 operational amplifier (amplify current) Accelerometers … chips etc.
without the computer
external power max 12 V (some versions can handle more) max 40mA per pins max 50mA on 3.3V pin
for your 9V battery
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
end
have you ever tasted a 9V battery? no more than 9V!
try different flavors ! wetdry
Ampere (current/flow) (A) Resistance (Ohm Ω) Voltage (pressure) (V) Water level
= electron particle
different flavors = different resistance electrons flow more or less easily wetdry
encoder