User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Blinking LED

Submitted by agreiner on Thu, 09/04/2008 - 16:11

Description

The lab required that we each set up a simple circuit with an LED that blinks according to instructions uploaded to the Arduino board from a laptop. We intially set the system up with the sample "blink" code from Arduino; then we changed the timing in the code and re-uploaded to make sure that the board was in fact getting our modified code.

Components Used

  • Light Emitting Diode (LED)
  • Resistor (220 Ohm)
  • Breadboard
  • Arduino board
  • Laptop running Arduino 11

Arduino Code

/*
* Blink
*
* The basic Arduino example.  Turns on an LED on for one second,
* then off for one second, and so on...  We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* http://www.arduino.cc/en/Tutorial/Blink
*/

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
}

 

After modification

 

/*
* Blink
*
* The basic Arduino example.  Turns on an LED on for one second,
* then off for one second, and so on...  We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* http://www.arduino.cc/en/Tutorial/Blink
*/

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(80);                  // waits for a fraction of a second
}