Tuesday 4 October 2011

CIRC-01: Blinking Lights

Purpose:
To get 1 LED to blink on and off in a 2 second span.

Equipment:
  • 1x Breadboard 
  • 1x Arduino Uno
  • 3x Wires
  • 1x 330 Ohm Resistor
  • 1x 5mm Yellow LED

Reference:
http://www.oomlout.com/a/products/ardx/circ-01


Program Details:
Because this is the first experiment, alot of new methods and hardware were introduced. In terms of new hardware, this experiment introduces the LED and the resistor. One thing to note when working with LEDs is that they only work in one direction, so it is important to make sure that the longer end connects to the positive end. Also LEDs require resistors, so they don't burn out if there is ever a surge.

In terms of new programming method, this program introduces the two required functions needed for arduino: void setup( ) and void loop( ). It also introduces methods such as pinmode(pin , mode); which you use to address which pin to activate with either an INPUT or OUTPUT. It also introduces digitalWrite(pin, value); which sets the OUTPUT to either HIGH (5 Volts) or LOW (Grounded). Finally the last method this program introduces is the delay(time); which sets a delay of however much you want, with 1 representing 1/1000 of a second.

To put this together we followed what the diagram show pretty closely, with the exception of the location of the LED on the breadboard. One wire went from ground to the (-) column, while the other went from PIN 13 to the (+) column. Then a wire went from the (+) column to to the positive end of the LED. Finally a 330 Ohm resistor went from the negative end of the LED to the (-) column.


Time to Complete:
5 Minute Build, 5 Minute Code


Results:
The circuit is very simple, and there is very little room for error. It worked as intended the first time I put it together.


Photo:






Tips:
You can save some time by going from PIN 13 directly to the positive end, as the (+) column connection really isn't necessary for this simple circuit.


Further Work:
In the future I may try to alter the constant blinking into a random pattern by using a Random variable in the delay( ); method.


Program Modifications:
I only made a very slight modification, which was making the LED blink more frequently. To do so I changed the delay(1000) --> delay(500).

Otherwise the code is the exact same as the one from:
http://www.oomlout.com/a/products/ardx/circ-01




Program:  
 
int ledPin =  13;               // Creates a variable for the PIN # 
 



void setup()                    // Runs once to initialize parts of the program
{                
  pinMode(ledPin, OUTPUT);      // Assigns LED 13 with an OUTPUT signal

}
 

void loop()                     
// Loops until there is no power                   
{
  digitalWrite(ledPin, HIGH);   // Gives PIN 13 a 5 Volt signal
  delay(500);                   // Creates an 0.5 second delay
  digitalWrite(ledPin, LOW);    // Pulls PIN 13 to ground
  delay(500);                   // Another 0.5 second delay
}                               // Loops again

No comments:

Post a Comment