
An introduction from the homepage, Arduino.cc:
"Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.
Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (based on Processing). Arduino projects can be stand-alone or they can communicate with software on running on a computer (e.g. Flash, Processing, MaxMSP)"
Affordances
The Arduino we use has six 10bit analogue inputs, 14 configurable digital pins, which can act as inputs or outputs; pins 0 and 1 are reserved for serial communication, pins 2 - 13 can be configured for digital in/out, and pins 9 -11 can be configured as a psuedo-analogue output, which is capable of PWM (Pulse Width Modulation).
The first exercise was to make an LED blink, and then make it blink using different code and a different circuit layout, using the Arduino to test if a connection was made between two pins on the board. Here is the idea, again from the the page http://arduino.cc/en/Tutorial/Blink
Blink
"In most programming languages, the first program you write prints "hello world" to the screen. Since an Arduino board doesn't have a screen, we blink an LED instead.
The boards are designed to make it easy to blink an LED using digital pin 13. Some (like the Diecimila and LilyPad) have the LED built-in to the board. On most others (like the Mini and BT), there is a 1 KB resistor on the pin, allowing you to connect an LED directly. (To connect an LED to another digital pin, you should use an external resistor.)
LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time). "
The code I used for this looks like this:
void setup()
{
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
This was then uploaded to the board using the Arduino IDE software. The LED was placed between Pin 13 9which has the required resistor built in, so as o avoid burning out the LED) and ground, and after 8 seconds, it began to blink.
The code is in two parts, the initial 'void setup()' section, which declares constants, and the 'void loop()' which runs over and over until the unit is stopped.
The second exercise used different pins, namely 5 and 10, and a wire was connected to the +5v on the board, and could be connected to pin 5. The LED was this time connected to pin 10, with a 150ohm resistor in front of it to prevent overload.
The second method's code was thus:
void setup()
{
pinMode(10, OUTPUT);
pinMode(5, INPUT);
}
void loop()
{
int state = 0;
state = digitalRead(5);
if (state == 1)
{
digitalWrite(10, HIGH);
}
else{
digitalWrite(10, LOW);
}
}
The loop here means that if pin 5 recieves a 1 (i.e., 5v) the output at ten will be high, and the LED will come on. The issue here is that, with the wire on pin 5 not connected to anything, it's state will wander randomly between 0 and 1, which is undesirable. Next post describes how to make this circuit in a more practical and correct fashion, using a switch....
And so, we have an Arduino working! Quite exciting!