Saturday, 7 January 2012

LED Fader Lamp Attempt

Leave a Comment


I am trying to make a simple fading LED lamp that fades-in and out multiple colors. I have 3 LEDs Red, Green and Blue in the same package. I turn them on simultaneously.

Trying to mix colors:

The combination colors were not very clearly visible. I haven’t made a diffuser yet. OK. I just placed a white envelope on it. The red being the most intense overwhelms the r+b, r+g and r+g+b with its color. Blue + Green looks sexy but I think I better diffusion would make it prettier.





Normalized Intensities:

Reduced intensity of Red.




still would love to know
  1. What is the best way (accurate method) to normalize the intensities and produce better colors
  2. Better ideas to diffuse light
/* Arduino Code*/
/*
Fading Triple Color RGB LED / PWM
Using Stub: Fading; By Tom Igoe
This example shows how to fade an LED using the analogWrite() function.
http://www.devilscafe.in
*/
/* Digital Pin Connections */
int redPin = 3;
int greenPin = 11;
int bluePin = 10;
int ledPin = redPin;
int colorSequenceTable[][3]={
{0xFF,0,0},    //Red
{0,0xFF,0},    //Green
{0,0,0xFF},    //Blue
{0xFF,0xFF,0},  //Yellow = Red + Green
{0xFF,0,0xFF},  //Magenta = Red + Blue
{0,0xFF,0xFF},  //Cyan = Blue + Green
{0xFF,0xFF,0xFF},  //White = Red + Blue + Green
{99,99,99}         //Terminate
};
void setup()  {
// nothing happens in setup
}
void loop()  {
mixrgb(100);
}
void mixrgb(int secs) {
for (int count = 0; colorSequenceTable[count][0] != 99; count++) {
// fade in
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(redPin, colorSequenceTable[count][0] & int(fadeValue/1.8));
analogWrite(greenPin, colorSequenceTable[count][1] & fadeValue);
analogWrite(bluePin, colorSequenceTable[count][2] & fadeValue);
delay(secs);
}
// fade out
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
analogWrite(redPin, colorSequenceTable[count][0] & int(fadeValue/1.8));
analogWrite(greenPin, colorSequenceTable[count][1] & fadeValue);
analogWrite(bluePin, colorSequenceTable[count][2] & fadeValue);
delay(secs);

0 comments:

Post a Comment