Making Furniture Interactive

September 4, 2007

Dan (Dongwoo) Kang: Exercise Zero

Filed under: Assignments,Dong Woo Kang,Exercise 0: Make A Lamp,Students — dwkang @ 12:04 am

layout 2* Effects:

There are three lamps each with the following colors- Blue / Green / Red

Blue and green lamps fade in and out at the same time and the red lamp fades in and out briefly while the light from the blue and green lamps is off. Blue and green lamps have a prolonged effect (10 seconds) whereas the red lamp lights up for a short period of time (1 second).

Once the red lamp goes off, the whole process starts over by blue and green lamps fading in.

You can click on the following youtube link to see how it works:          http://www.youtube.com/watch?v=G_EUT_imGD8  

* Parts used:

           – Three LEDs: Blue / Green / Red

           – Wires

           – Breadboard

           – 3 resistors

           – Arduino Board

           – Straws

* Layout:

The blue lamp gets its power from pin# 10, the red lamp from pin# 11, and the green lamp from pin# 9 of the Arduino board. There are wires that connect the longer leg (+) of each LED to the corresponding pins listed above.

The shorter leg (-) of each LED lamp is connected to the negative column on the breadboard through the resistor. The three resistors then send the power back to the ground pin on the Arduino board through one wire that is placed on the top of the negative column.

dscn0556.jpg

layout 2

* Code:

// Fading LED

// by BARRAGAN <http://people.interaction-ivrea.it/h.barragan&gt;

int value = 0;                            // variable to keep the actual value

int ledpinblue = 10;                           // light connected to digital pin 10

int ledpinred = 11;                       // light connected to digital pin 11

int ledpingreen = 9;                      // light connected to digital pin 9

void setup()

{

  // nothing for setup

}

void loop()

{

  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)

   {

    analogWrite(ledpinblue, value);           // sets the value (range from 0 to 255)

    analogWrite(ledpingreen, value);

    delay(100);                            // waits for 30 milli seconds to see the dimming effect

  }

  for(value = 255; value >=0; value-=5)   // fade out (from max to min)

  {

    analogWrite(ledpinblue, value);

    analogWrite(ledpingreen, value);

    delay(100);

  } 

for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)

   {

    analogWrite(ledpinred, value);           // sets the value (range from 0 to 255)

    delay(10);                            // waits for 30 milli seconds to see the dimming effect

  }

  for(value = 255; value >=0; value-=5)   // fade out (from max to min)

  {

    analogWrite(ledpinred, value);

    delay(10);

  } 

}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: