Making Furniture Interactive

August 30, 2007

Exercise Zero: Make A Lamp

Filed under: Assignments,Exercise 0: Make A Lamp — mdgross @ 11:53 am

(Due Sept 4 2007): Build a lamp (an illuminating device – for example, a nightlight is considered a lamp here) that uses three colors of LEDs – to make different colors and/or patterns in time of light. Assignment details are in the PDF linked here:
PDF for Exercise Zero



  1. hi guys,

    i’m trying to repeat some code i’ve written (kind of a frankenstein beast combining some shreds of a few exercises, but it just stops after fading on and then ends. also, i was wondering if you could show me a link to a place that tells you how to activate more than one led at a time, i can’t seem to figure it out (eg to create color shifting lamps, etc)

    much appreciated!


    Comment by tom gonzalez — August 30, 2007 @ 11:17 pm | Reply

  2. I just posted a link to an LED tutorial, but I don’t think it’s quite what you want (but you may want to read it anyhow).

    You want to light a RED and a GREEN LED. You want to control them independently, that is, be able to turn on the RED or GREEN or both, or neither.

    First let’s make sure that you have a reasonably wired circuit.

    So – connect the RED LED to one of your output pins (say “digital pin 4”). You will connect the anode (+, or longer side) of the LED to the output pin, and then a resistor to the other (-, or shorter side) of the LED, and then the resistor back to Ground. Once you have this hooked up right, then you can control it with your program.

    The program will need to declare a variable (say REDLEDPIN) to be pin 4, and an OUTPUT pin.
    int REDLEDPIN = 4;
    pinMode(ledPin, OUTPUT);

    One you have done this, whenever you digitalWrite(REDLEDPIN, HIGH) you will turn the LED on, and digitalWrite(REDLEDPIN, LOW) you will turn it off.

    To do this for more than one LED, repeat all this, for each LED – say, use pin 5 for the GREEN, and pin 6 for the BLUE.

    That’s only for if you want to turn the LEDS on and off. If you want to fade them you must use pins 9,10, and 11, and declare them analog pins instead of digital, and use analogWrite instead of digitalWrite.

    Now that you’ve got the hardware right, test it. If you’re doing the FADING program, first try it with one LED (as in the demo program). OK, now add a little code to turn on the second LED (right after you turned on the first one), and to turn it off again (right after you turned off the first one).

    Comment by mdgross — August 31, 2007 @ 12:28 am | 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: