My LED Fader Lamp Attempt
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.
I still would love to know
- What is the best way (accurate method) to normalize the intensities and produce better colors
- Better ideas to diffuse light
Cheers!
Manav
—
/* Arduino Code*/
/*
Fading Triple Color RGB LED / PWM
Manav Kataria/1st April 2010Using Stub: Fading; By Tom Igoe
This example shows how to fade an LED using the analogWrite() function.
http://arduino.cc/en/Tutorial/Fading
*//* 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);
—
I think .. the second color should begin.. BEFORE the first color is OFF completely..
Secondly .. for yellow.. u may not need red in its full intensity.. so reduce it from 0xff to something less.. play around with those numbers..
and reduce the delay..
April 2, 2011 at 7:35 am
Will try that combo! Thank you for your feedback, Mr. ABA 😉
I agree that the red intensity needs to be reduced further.
April 2, 2011 at 8:55 am
Awesome!!!
April 2, 2011 at 7:04 pm
Thanks Mohit! 🙂
April 4, 2011 at 5:22 am