Making Furniture Interactive

September 4, 2007

lamp

Filed under: Exercise 0: Make A Lamp,Ronit Slyper — Ronit @ 4:32 pm

Steps

  1. I began by sticking a glowing LED into every blown glass piece I’ve made. Those of a transparent color looked bad because you could see the circuitry inside, so I finally settled on this piece:
    Items of the Lamp, which inside is hollow like so:Inside of Glass Thing.
  2. Next it was time to solder, so the LEDs could reach inside the lamp. I soldered wires onto the ends of 5 LEDs (the novelty wore off fairly quickly). Soldering
  3. Setting up. The LEDs were positioned to line up with the glass thing’s four eyes, plus one LED near the top. Five wires ran from the Arduino, to the prototyping board, and attached to 5 resistors, which went through the LEDs and then to ground, as shown in the wiring diagram. The four eyes’ wires were digital; the other was analog.Circuitrywiring
  4. .

  5. The code pulses the red light, then open’s the glass figure’s “eyes”, has it blink a bit, then plays with different eye-blinking patterns.
    /*
    * Lamp
    * by Ronit Slyper
    *
    * 2 - bottom right
    * 3 - bottom left
    * 4 - top right
    * 5 - top left
    * 9 - top red, PWM
    */int timer = 100;                   // The higher the number, the slower the timing.
    int pins[] = { 2, 3, 4, 5 }; // an array of pin numbers
    int num_pins = 4;                  // the number of pins (i.e. the length of the array)
    int pwmPin = 9;
    int mode = 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 shortdelay = 40;
    int longdelay = 1000;
    int i, j;
    // begin code
    if (mode==0) {                  // red warning light
    for (j = 0; j < 5; j++) {
    for (i = 0; i =0; i-=5) {
    analogWrite(pwmPin, i);
    delay(shortdelay/2);
    }
    } // end foreach j
    } else if (mode==1) {                    // cute blinky thing
    digitalWrite(2, HIGH);
    delay(longdelay);
    digitalWrite(3, HIGH);
    delay(longdelay);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    delay(longdelay);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    delay(longdelay * 3);
    digitalWrite(4, HIGH);
    delay(longdelay);
    digitalWrite(5, HIGH);
    delay(longdelay);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(longdelay);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(longdelay * 4);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    } else if (mode==2) {
    for (i = 0; i < 5; i++) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    delay(longdelay * 2);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(longdelay * 2);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    }
    } else if (mode==3) {
    for (i = 0; i < 5; i++) {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    delay(shortdelay);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(shortdelay);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    analogWrite(pwmPin, 51 * i + 51);
    delay(shortdelay);
    analogWrite(pwmPin, 0);
    }
    } else if (mode==4) {
    for (i = 0; i < 20; i++) {
    digitalWrite(2, HIGH);
    digitalWrite(5, HIGH);
    delay(longdelay);
    digitalWrite(2, LOW);
    digitalWrite(5, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    delay(longdelay);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    }
    } else if (mode==5) {
    for (i = 0; i < 5; i++) {
    analogWrite(pwmPin, 255);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(longdelay);
    analogWrite(pwmPin, 0);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    }
    } else if (mode==6) {
    delay(longdelay);
    }
    delay(shortdelay);
    mode++;
    mode %= 7;
    }
    
  6. The results looked really cool in the extreme dark: Lighted Lamp
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: