User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Blinking LED Breadboard

Submitted by sarah_vanwart on Sun, 09/07/2008 - 09:31

Description

The purpose of this lab was to:

  1. install the Arduino software and drivers,
  2. get the computer to communicate with the Arduino board,
  3. construct a simple circuit that makes a LED light blink, and
  4. modify the program in order to modify the interval and length in which the LED blinks.

Components Used

  • Arduino board
  • Red Light Emitting Diode
  • 220 Ohm Resistor (red, red, brown, gold)
  • USB Cable (for power)
  • Wires

Arduino Code

Initial Code:

int ledPin = 13;                      // LED connected to digital pin 13
void setup()                          // run once, when the sketch starts
{
   pinMode(ledPin, OUTPUT);           // sets the digital pin as output
}
void loop()                           // run over and over again
{  
   digitalWrite(ledPin, HIGH);        // sets the LED on
   delay(1000);                       // waits for a second
   digitalWrite(ledPin, LOW);         // sets the LED off
   delay(1000);                       // waits for a second
}

Modified Code:

I just tinkered with the code a little bit to make the delay time twice as long for each iteration of the loop.  Each time the LED blinked, it lasted twice as long and turned off for twice as long than the time before:

int ledPin = 13;                // LED connected to digital pin 13
int delayTime = 1;              // **Initial delay time

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()                     // run over and over again
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(delayTime);             // "on" for "delayTime" amount of time.
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(delayTime);             // "off" for "delayTime" amount of time.
  delayTime = delayTime*2;      // double the delay time.
}

Photograph

Credits

  1. Nick Rabinowitz, who helped me debug my driver installation issues.
  2. Patrick Goodwill, who reminded me that the LED legs were polarized (short leg touches ground).
  3. My neighbor (forget her name) who stayed after to try and help me get my circuit to work.