1.08k likes | 1.25k Views
#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.
E N D
#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
shape allows users to pick up and move light sensors, to allow sending commands to the tangible (onmi) wheels and motor, so it can move itself your task: design & built a motorized tangible object
and a set of components (battery / motors / photoresistors / chips / resistors …)
program on PC (simplified C++) • upload to the board • separate and run independently main advantage of Arduino!
when programming and testing pins some LEDs usb plug (5V) processor reset button to run independently external power (max 12v) pins
pins some LEDs usb plug (5V) reset button processor external power (max 12v) pins: to plug in components such as… pins
+ - long leg is the + LEDs
the LED blinks continuously (we will see later why we need the resistor) pin “gnd” (ground) pin “12” what’s happening?
0 configure
1 pin “gnd” (ground) pin “12” pluging in
e.g. all these pins are connected It is the same here etc. test board
2 compiling
3 uploading
it isblinking: the board is uploading the binary code (1 = light on / 0 = light off) 3 uploading
4 1st loop executing
5 executes setup () reseting
test 1 (5 mn) blinking LED • plug in a resistor and an LED in pin 12 • launch the File/Examples/Basic/Blink arduino files • modify the code to make the LED says “SOS” in Morse (3 shorts, 3 longs, 3 shorts) 82 ohm - + pin gnd Blue LED pin 12 (5 V)
don’t forget your programming skills! write functions
test 2 (5 mn) more blinking (with the same circuit) • upload File/Examples/Basic/Blink to the board • change the first delay value to 1 and the second to 1. upload the code to the board • change the first delay value to 1 and the second to 10. upload the code to the board • compare the three cases and tell me more!
delay(1000) … delay(1000) HIGH blink bright LOW 1 2 3 delay(1) … delay(1) less bright blink delay(1) … delay(10) even less bright blink
delay(1000) … delay(1000) HIGH voltage is either 0 or 5v LOW 1 2 3 delay(1) … delay(1) voltage is ½ of 5V delay(1) … delay(10) voltage is a 1/11 of 5 V
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) smooth blinking • change your circuit to use a PMW pin • write code with analogWrite() to make the led smoothly blink (the brightness progressively increases)
digitalWrite("pinnumber”,”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
by the way, components that generate high voltage will damage the board, be careful! pin “A0” pin “gnd” 1.5V battery on A0 pin to read it voltage
Monitor display Serial.print() Serial,println() 305 305 305 305 305 305 305 305 305 305 305 305 305 of [0;1023] so 305x5/1023 = 1,49V
voltage increases when the intensity of light increases photodiode
voltage increases when pressure increases piezoelectric cells
but also with components that generate resistance • (and we will see the trick later)
material in what components are plug in it removes electrostatic charges conductive foam
it lets the charge passing thought: it conduces charges the more you squeeze it, the less it resists to the travel of the charges conductive foam
pin “A0” pin “gnd” let’s play with a piece of conductive foam
test 4 (5 mn) read pins • plug in two wires and a piece of foam between pin A0 and GND • write code to display the change of voltage on pin A0 • write code to make an LED more or less bright when you squeeze the foam