Arduino at K3 August 2007
home - people - contents - location
| Mon, Aug 27th | Tue, Aug 28th | |
|---|---|---|
| 9.00 | arrival | |
| 9.15 | intro | |
| | | ||
| 10.00 | session 1 | session 3 | PD intro |
| | | ||
| 11.00 | ||
| | | ||
| 12.00 | lunch | lunch |
| | | ||
| 13.00 | session 2 | session 4 |
| | | ||
| 14.00 | ||
| | | ||
| 15.00 | end day 1 | Processing intro |
| | | ||
| 16.00 | end workshop |
Introduction
link: slideshow used for the presentation
[click on the pictures to see the information]
Session 1 - Digital Input/Output
- Introduction to Arduino
- Install party: get the software running
- Basic Output examples: LED Blink
- Knight Rider exercise
- Using the breadboard
- Components: LED (polarity), resistor (ohms, no polarity)
- Software commands: pinMode(pin, INPUT/OUTPUT), digitalWrite(pin, HIGH/LOW), delay(time), digitalRead(pin), if (statement) {} else {}
- Software structures: variable declaration, void setup(), void loop()
- Color coding: Red (voltage), Black (ground), others (signals)
- Digital values: HIGH - ON - 5V - 1 - TRUE // LOW - OFF - 0V - 0 - FALSE
- digital inputs: using a wire, using a button, using a pull-up resistor
- difference between assigning (=) and comparing (==)
- Recommended materials: Evan's programming booklet, Banzi's arduino booklet, installing arduino on Mac
Session 2 - Analog Input/Output - Serial Comm. #1
- analog input: analog digital conversion (ADC), more info
- Software commands: val = analogRead(pin), analogWrite(pin, value), delayMicroseconds(time), for(init;until;increment)
- MCU's way of reading analog signals: reading voltage
- Components: potentiometer, piezo, LDR
- Circuits: basic resistive sensor connection, piezo as a speaker
- analog output: Pulse Width Modulation (PWM), fading control with Potentiometer
- Sound production: period = 1/frequency, generating tones
- Serial library: Serial.begin(speed), Serial.print(data), Serial.println(data), Serial.print(data,BYTE)
- Serial monitors: Zterm for Mac, BrayTerminal for Windows, GTKTerm for Linux
Session 3 - Serial Comm. #2 - Puredata
- Software commands: creating functions, using parameters
- Serial library: Serial.available(), Serial.read()
- using puredata: objects, messages, numbers, events, sliders, netsend, netreceive
- check the PD intro further down
Session 4
- complex sensors: measuring the environment requires the use of intelligent sensors that include their own microprocessors to handle data. Examples of this are accelerometers, ultrasound, infrarred, etc.
- it is good to consider what we are measuring from an abstract point of view and then see which tools will make it possible afterwards. E.g. if we want to measure presence, we should consider different types of sensors to do that: LDRs for close distances (<10cms), IR for intermediate distances (10-80cms), US for long distances (30cm-10m)
- using the ultrasound sensor PING from Parallax: the trick is to use one pin both as input and output during the loop. The way to do this goes through changing a pin's configuration interactively in the process using pinmode(pin,INPUT/OUTPUT). The sensor acts very much like a sonar, sending one US signal when requested, and listening to the echo coming back. The result is expressed by the sensor as a pulse which width denotes the distance to the object in front of it. The US sensor is very accurate, but has to be placed at the object's nose
- Example with the PING sensor
- components: piezo element
- using PWM (Pulse Width Modulation) to write analog signals to outputs
- sound production: frequency = 1/period, generating a computer keyboard on Arduino controlled through the serial port, code example: el pianito
- example to test how Arduino sends data to Processing: processino
PD intro
- created by M. Puckette, distribution maintained by H.C. Steiner
- native (C) software package, multiplatform
- allows the creation of code through visual commands
- used for handling flows of data, mainly in sound production, but also video, 3D, etc
- there is an object called comport that allows reading data from a serial device, it has two parameters: port number, and communication speed
- thanks to that object we can both send and receive data into/from Arduino
- there is an Arduino program called Firmata by H.C. Steiner that allows to read/write all the pins from/to Arduino from yet another PD object called arduino
- People tend to ask about the relationship between PD and MAX/MSP, this article from IRCAM makes the best introduction ever to the subject (taking away any intrigues)
Processing intro
- created by C. Reas and B. Fry with support among others from the MIT Medialab
- Java software package, multiplatform
- simplifies the creation of code-made animations
- used for interactive installations, motion capture, web production, video postproduction, etc
- there is a library called Serial that includes a whole series of commands to read/write data from/to the serial port
- print(Serial.list()) will print a list of all the available ports in the system, together with a number that will identify them
- the port is created as a software object: myPort = new Serial(this, Serial.list()[number], 9600)
