Arduino is a microcontroller that allows the user to any number of things. Think of the Arduino as a small computer that can gather data from the outside world through various sensors and then can affect the environment based on that information using lights, motors or actuators. Arduino is inexpensive, relatively easy to learn, and lends itself well to interactive exhibit design. For more information on Arduino specifics, please see the following sites: Arduino works with a programming environment based on Processing, in which the user defines how the Arduino will work. I have had a few opportunities to explore the Arduino, which I will outline below. LED SOS This small project was done by Jordan Goldstein, Dana Johnson and myself, and consisted of an LED programmed to blink SOS in Morse Code. The following is the code we used.
//Based on Blink by David Cuartielles */ int i = 0; int ledPin = 10; void setup() { pinMode(ledPin, OUTPUT); } void loop() { for(int i = 0; i <= 2; i++) { digitalWrite(ledPin, HIGH); // set the LED on delay(500); // wait for a half second digitalWrite(ledPin, LOW); // set the LED off delay(500); // wait for a half second } for(int i = 0; i <= 2; i++) { digitalWrite(ledPin, HIGH); // set the LED on delay(1500); // wait for a second and a half digitalWrite(ledPin, LOW); // set the LED off delay(500); // wait for a half second } for(int i = 0; i <= 1; i++) { digitalWrite(ledPin, HIGH); // set the LED on delay(500); // wait for a half second digitalWrite(ledPin, LOW); // set the LED off delay(500); // wait for a half second } { digitalWrite(ledPin, HIGH); // set the LED on delay(500); // wait for a half second digitalWrite(ledPin, LOW); // set the LED off delay(2000); // wait for two seconds } } Traffic Light A second project Jordan, Dana and I completed that day was creating an LED traffic light with green, yellow and red LEDs. Below are the code we used and a video of a similar project I completed later.
//Based on an original by H. Barragan */ int i = 0; int redPin = 10; // RedLED connected to digital pin 10 int greenPin = 4 // GreenLED connected to digital pin 4
int yellowPin = 6; // YellowLED connected to digital pin 6 void setup() { pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
} void loop() {
digitalWrite(greenPin, HIGH); // set the GreenLED on delay(1500); // wait for a second and a half digitalWrite(greenPin, LOW); // set the GreenLED off delay(50); // wait for a fifth of a second digitalWrite(yellowPin, HIGH); // set the YellowLED on delay(500); // wait for a half second digitalWrite(yellowPin, LOW); // set the YellowLED off delay(50); // wait for a fifth of a second digitalWrite(redPin, HIGH); // set the RedLED on delay(1500); // wait for a second digitalWrite(redPin, LOW); // set the RedLED off delay(50); // wait for a fifth of a second }
Accelerometer A third project we undertook with the Arduino was to use an accelerometer – a sensor that conveys data about position and movement like a Wii remote. Dana, Becca Rahey and I endeavoured to create a circuit and program that would allow us to turn the Arduino’s built-in LED on when the board tilted past a predetermined position. This project used only one of three possible axes but provided proof of concept. Below is a video of our results and the code we used. You will notice that a lot of the code that we started with was simply tuned off [//]. I have left these lines in case someone wanted to reuse the code.
/* http://www.arduino.cc/en/Tutorial/ADXL3xx
The circuit: modified 27 Jan 2010 by Tim O’Grady, Dana Johnson and Becca Rahey */ //
these constants describe the pins. They won't change:
// Provide ground and power by using the analog inputs as normal void
loop() Arduino Button, with Megan Arnott Potentionmeter with Megan Arnott |