Arduino

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.

 

 /*
  ADXL3xx
 
  Reads an Analog Devices ADXL3xx accelerometer and communicates the
  acceleration to the computer.  The pins used are designed to be easily
  compatible with the breakout boards from Sparkfun, available from:
  http://www.sparkfun.com/commerce/categories.php?c=80

  http://www.arduino.cc/en/Tutorial/ADXL3xx

  The circuit:
  analog 0: accelerometer self test
  analog 1: z-axis
  analog 2: y-axis
  analog 3: x-axis
  analog 4: ground
  analog 5: vcc
 
  created 2 Jul 2008
  by David A. Mellis
  modified 26 Jun 2009
  by Tom Igoe

  modified 27 Jan 2010

  by Tim O’Grady, Dana Johnson and Becca Rahey

 */

 // these constants describe the pins. They won't change:
 const int groundpin = 18;             // analog input pin 4 -- ground
 const int powerpin = 19;              // analog input pin 5 -- voltage
 const int xpin = 3;                   // x-axis of the accelerometer
 const int ypin = 2;                   // y-axis
 const int zpin = 1;                   // z-axis (only on 3-axis models)
 const int onboard = 13;              // onboard LED
 int xvalue;
 
 void setup()
 {
    
   // initialize the serial communications:
   Serial.begin(9600);

   // Provide ground and power by using the analog inputs as normal
   // digital pins.  This makes it possible to directly connect the
   // breakout board to the Arduino.  If you use the normal 5V and
   // GND pins on the Arduino, you can remove these lines.
   pinMode(groundpin, OUTPUT);
   pinMode(powerpin, OUTPUT);
   pinMode(onboard, OUTPUT);
   digitalWrite(groundpin, LOW);
   digitalWrite(powerpin, HIGH);
 }

 void loop()
 {
   xvalue=analogRead(xpin);
   if(xvalue <=550) {
   digitalWrite(onboard,HIGH);
   delay(200);
   }
   if(xvalue >550) {
   digitalWrite(onboard,LOW);
   delay(200);
 }
  
   // print the sensor values:
   Serial.println(analogRead(xpin));
   // print a tab between values:
   // Serial.println("\t");
   // Serial.println(analogRead(ypin));
   // print a tab between values:
   // Serial.println("\t");
   // Serial.println(analogRead(zpin));
   // Serial.print();
   // delay before next reading:
   delay(100);
 }



Arduino Button, with Megan Arnott

YouTube Video



Potentionmeter with Megan Arnott

YouTube Video