Making Furniture Interactive

September 5, 2007

Exercise Zero: Jamin

Filed under: Exercise 0: Make A Lamp,Jamin Hegeman — Jamin Hegeman @ 10:50 am

Being new to this, I started with the loop tutorial on the Arduino site. I altered the tutorial, which was for six LEDs to work for three LEDs.
LEDs and breadboard

Once I got that working, I substituted the code in the tutorial that made the LEDs blink with the code from the Arduino program example, Analog Fading, so they would fade in sequence. Next, I played around with random variables so that the LEDs would fade in and out in random sequence. The I increased the delay for fading in so that it was slower than the fade out. Also, I added a random delay between the fade in/fade out, so that LED would stay on for a random period of time.

int pins[] = { 9, 5, 3 }; // an array of pin numbers
int num_pins = 3; // the number of pins (i.e. the length of the array)
int value = 0;

void setup()
int i;

for (i = 0; i < num_pins; i++) // the array elements are numbered from 0 to num_pins – 1
pinMode(pins[i], OUTPUT); // set each pin as an output

void loop()
int i;

int r = random(num_pins);
int rt = random(10);

for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
analogWrite(pins[r], value); // sets the value (range from 0 to 255)
for(value = 255; value >=0; value-=5) // fade out (from max to min)
analogWrite(pins[r], value);

For the lamp, I used a paper candle holder I created last year, which fit nicely over the breadboard. The bluish white light worked well when on.

lamp with blue light

Unfortunately, the red and green lights didn’t shine so brightly.

lamp with red and green lights


1 Comment »

  1. yes, I just grabbed some LEDs from the drawer, not looking to see that their brightness was matched. LED characteristics (when you buy them this is what to look for) include physical size (in mm), current draw (in milliAmps), and brightness (in millicandelas).

    Comment by mdgross — September 5, 2007 @ 5:59 pm | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Create a free website or blog at

%d bloggers like this: