User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Assignment 1 - Blinking LED

Submitted by michael_lee on Mon, 09/08/2008 - 15:18

Description

Setting up an LED to blink using the arduino.

Components Used

  • Light Emitting Diode (LED)

  • Resistor

  • Wires

  • Breadboard

  • Arduino NG

Source Code

Here is my code for the Arduino. I used a random number for the blinking on and off to make it a little annoying ;)

/*
* 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(random(500,5000));                  // waits for a random time between half a second to 5 seconds
digitalWrite(ledPin, LOW);    // sets the LED off
delay(random(500,5000));                  // waits for a random time between half a second to 5 seconds
}

Image