Friday, April 1, 2011

D, I & E Intensive Day 1

Today we learnt about Arduino and basic electrical circuits. Arduino is an open-source electronics prototyping platform centred around a microprocessor that is controlled by uploaded code. The microprocessor can be stand-alone or can interact with software running on a computer.  The development environment is based on Processing, which is also open-source. As with Processing, Arduino has a large community of users including many artists and visual designers.

I have already been using Processing and am excited to take projects beyond the computer. So the point of Arduino is that the microprocessor facilitates interaction with the environment including human interfaces beyond the screen, keyboard and mouse. Inputs can be considered environmental sensors that measure things like sound, light, heat, movement. A very cute example is Rob Faludi's Botanicalls that measures soil moisture and sends tweets to remind you to water your plants and then once you have sends another tweet thanking you.

Botanicalls, Rob Faludi and SparkFun
Outputs can include sound, lights and motorised movement and are often understood to respond to the environmental sensors, although it is not necessary to use dynamic/interactive inputs and outputs at the same time.

We started with a tutorial by Lady Ada to upload code to the microprocessor that caused a LED to blink. This apparently is the hardware equivalent of a hello world.

Arduino microprocessor with simple circuit (blinking LED)
We setup our circuit on a breadboard which has rows of already connected pins that make it easy to 'plug and play'. It consists of a light emitting diode (LED), a resister for safety and wires for signal and ground connected to the Arduino microprocessor. The ground wire is connected to the ground pin (marked GND) and the signal wire is connected to a digital pin, which can only give high voltage or low voltage (ground or 0) - that is on/off.

The colour of cables is used to organise the circuit with clarity - we are using black for ground and red for high voltage (apparently these are conventions), and then green and orange for variable signals as input and output respectively.

Resistors are important to restrict the current, both to ensure that fragile parts such as the diode dont get fried and to reduce the risk of electrocution. I am not yet totally across when to use resistors and how much resistance to choose - I suppose it always somewhat necessary to check specification of parts. Lady Ada  suggests that a 100 ohm resistor is sufficient to protect a diode and that generally a 1000 ohm  (1K ohm) resistor is a good place to start. The relationship between current, resistance, and voltage is described by Ohm's Law: Current (I) = Voltage (V) / Resistance (R). The level of resistance is notated with coloured bands.

The way we controlled the blink is with simple code that in the loop function (equivalent to the draw function in Processing) says light on (high voltage signal), then delay (pause the program, light remains on), light off (low voltage signal) and then delay again (pause the program, light remains off).

We also learnt about drawing circuit diagrams, as you can see in the background of the above picture.

The next project was to reconfigure the circuit to make the LED dim-able. We added a flex sensor as an input - it is a variable resistor that changes input signal (voltage drop) as it is bent. The input and output signal had to be connected to an analog pin on the Arduino microprocessor. The analog pins (marked ~ ) can use pulse width modulation (PWM) to vary voltage - how this actually works is that the duty cycle or the amount of time that is high or low each clock cycle can be set between 0 (always low) and 255 for output or 1023 for input (always high) effectively turning on/off so quickly that it is imperceptible and appears as continuous and smooth. As there are different ranges for the input and output values it is necessary to calibrate - in this case we offset the input value to be below 255.

LED dimmed using flex sensor as input

No comments:

Post a Comment