Making Furniture Interactive

September 4, 2007

pingponglamp.beste.A0

Filed under: Beste Nazilli,Exercise 0: Make A Lamp — botto @ 11:42 pm

I started with the default fading code, and modified it to make 3 consequent fading LEDs.

Steps:

Step 1 |

Step 1| At first, without any lamp ideas, I just wanted to make a working code for 3 fading lamp. So I just put the LEDs on the breadboard. It took me a while to figure out that some PWMs are enough for fading sequence. But still green LED is giving out a poor light but I think it is because of lamp itself.

Step 2 |

2 | After the code worked as I wanted, I started to think how will I make it look like a lamp. I took out the LEDs from board and bent wires and pins going into the LED to make them attach to each other.

Step 3 |

3 | I cut 3 ping pong balls and gathered to each other vertically.

Step 4 |

4 | So I put each LED set to one of the bulbs and tried to make them light up consequently.Because of the LEDs light power difference, some of them become dominant to others.

———————————

I really had fun to play around with the LEDs !

And here is the code:

int timer = 255; // The higher the number, the slower the timing.
int pins[] = {
3, 5, 6 }; // 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;

for (i = 0; i < num_pins; i++) {

for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
{
analogWrite(pins[i], value); // sets the value (range from 0 to 255)
delay(30); // waits for 30 milli seconds to see the dimming effect
}
}
for (i = num_pins – 1; i >= 0; i–) {
for(value = 255; value >=0; value-=5) // fade out (from max to min)
{
analogWrite(pins[i], value);
delay(30);
}
}
}

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: