DSCN5326.JPG
DSCN5319.JPG
DSCN5331.JPG
DSCN5332.JPG
DSCN5333.JPG
DSCN5334.JPG
Hi! In this tutorial you will learn to make a mood lamp with arduino.
I know that you may have seen a lot of mood lamp projects with arduino, but I wasn't very satisfied with them because they all change the color very abruptly. So, I decided to make a smooth mood lamp and I also made it to turn on only when the room is dark.
This project is good for those who are beginners in the arduino's world.
 
Remove these adsRemove these ads by Signing Up
1-40 of 48Next »
eliara says: Jun 4, 2013. 4:51 PM
Oi , montei esse projeto , mas o meu só fica piscando em azul os leds o que faço?
ricardouvina (author) in reply to eliaraJun 9, 2013. 5:01 AM
Olá, verifique se todos os caminhos que você montou estão como no esquemático e para garantir baixe o arquivo ZIP ao invés de copiar direto da página. Se ainda não funcionar me avise, ficarei feliz em ajudar. Ah, e você é a primeira brasileira a comentar aqui! =)
d4ng says: Jun 4, 2013. 1:39 PM
Great Instructable! My first "real" Arduino project.

I am attempting to change/add the colors the my RGB LED cycles through.
I have attempted several things but am hitting a dead end..any ideas?
knobhill says: May 17, 2013. 6:56 AM
I like the project a lot - good work - I want to try putting one together, but if I wanted to modify things so that the leds work under any light (it doesn't have to be pitch black ), how would I go about doing that ?
ricardouvina (author) in reply to knobhillMay 18, 2013. 6:49 PM
Just remove the following lines:
if(ambientLight>600){ // start only if the ambient light is very low
// write the brightness on the leds
analogWrite(redLed,RGB[0]);
analogWrite(greenLed,RGB[1]);
analogWrite(blueLed,RGB[2]);
}
else{
digitalWrite(redLed,LOW);
digitalWrite(greenLed,LOW);
digitalWrite(blueLed,LOW);
}

and substitute them by:
analogWrite(redLed,RGB[0]);
analogWrite(greenLed,RGB[1]);
analogWrite(blueLed,RGB[2]);
without the if loop.
I haven't tried this but I think this should work.
louisbourdon says: May 1, 2013. 7:48 AM
I have tried of course to use a break inside the for loop, however it does not work!!! I have tried using an outside command via OSC, and also hit a key from the Serial Monitor to break the loop. Nothing works, it looks like it is stuck there - like it waits to finish the whole loop and then exit. But I want to make it happen instantly but so far nothing works! If anyone has a tip, that would be great!
louisbourdon says: Apr 30, 2013. 6:21 PM
Hi, nice project. I would like to ask you, how is it possible to escape the for loop? I want to use this as a feature in my project against other features (i.e. Mode 1 - All lights off, Mode 2 - All lights on, Mode 3 - Mood Lights). Using a control I want to go from one mode to the other, however, when I use this for loop everything gets stuck as it is a very long loop and takes for ever to complete. What do you suggest?

for (float x=0;x RGB[0]=255*abs(sin(x*(180/PI))); // calculate the brightness for the red led
RGB[1]=255*abs(sin((x+PI/3)*(180/PI))); // calculate the brightness for the green led
RGB[2]=255*abs(sin((x+(2*PI)/3)*(180/PI)));// calculate the brightness for the blue led
}
ricardouvina (author) in reply to louisbourdonMay 1, 2013. 6:44 AM
What you can do is use a "break" inside the "if" loop to stop it, but use it carefully, otherwise it can be very harmful.
pabhilash says: Jan 7, 2013. 4:30 AM
Hello again! never mind, it's working fine now! i misplaced a wire :P thanks so much! may i suggest something? when you define the ambient light settings, you should try changing it to 900 instead of 700. under 700, the LED's glow even in a fairly lit room! :)
ricardouvina (author) in reply to pabhilashJan 19, 2013. 4:37 PM
OK! That value is up to you. You choose what better works to you!
pabhilash says: Dec 23, 2012. 1:58 AM
Hello! great I'ble! There seems to be a small problem- uploading gets done fine, but immediately the LED(RGB) just glows light blue,even in a well lit area! and the color does not change! could you please help?(it's an Uno by the way..)
ricardouvina (author) in reply to pabhilashDec 23, 2012. 4:16 PM
Did you download the zip file, or did you copy the code from the step and paste it on arduino's program?
sarah91 says: Dec 12, 2012. 2:33 AM
What do I change when it is 1 red LED, 1 green LED and 1 yellow LED?
ricardouvina (author) in reply to sarah91Dec 12, 2012. 12:19 PM
Nothing. You will just get different colors than mine.
geoffb37 says: Oct 19, 2012. 10:34 AM
hi
me again, how can i get it to cycle thru green/ it does blue thru red/orange/purple but not green?
Vertec says: Oct 15, 2012. 11:29 AM
Hi , I really like your project , I was trying to build it , and i am stuck in a situation that i am using RGB LED , (one that you have shown in your project also first image) but I have common anode , it change the light effect exactly as you describe in your project , but my LDR is not working , means its not light sensitive,
1) For the common anode RGB LED , only the polarity of the wires will be change (if i follow your design) ? or any thin else
Vertec in reply to VertecOct 17, 2012. 10:11 AM
Hi , Thanks for your reply can you please tell me the value of the resistor you have used for it , or the minimum value of the resistor i can use with the LDR? (it must be start with 10k at least) if i am not wrong !
ricardouvina (author) in reply to VertecOct 18, 2012. 2:17 PM
I used a 120k resistor, but anything between 10k and 1M should work just fine, but remember to adjust the ambient light threshold as I said before.
I hope you can make it! :)
ricardouvina (author) in reply to VertecOct 16, 2012. 4:58 PM
Hi.
Yes, for the common anode RGB LED only the polarity changes, you must be having trouble with the LDR due to the value of the resistor that you're using with it, try to change the ambient light threshold, try to adjust the code at:
if(ambientLight>600){ // start only if the ambient light is very low

change the number 600 to a value that works for you, try to increase or decrease it.
Ozzie_G says: Oct 13, 2012. 7:16 AM
Nice little project, Thanks

What exactly are you trying to achieve with the delays depending on the current brightness of all three channels?

ricardouvina (author) in reply to Ozzie_GOct 14, 2012. 6:16 AM
Hi!
Show all the colors in a long period of time, otherwise the red, blue and green colors would be on for a very short period of time, and it would change very quickly and I wanted it to be very smooth.

Thanks for your comment!
ponynicker53 says: Oct 6, 2012. 7:36 PM
My RGB LED has the second lead as positive, and all the colors as negative. So when I wire it as described, with the long terminal on the LED hooked to ground, nothing happens. When I move that wire to the positive (5V), it lights up, but constantly and all colors are on.
Any ideas how to get it working?
ponynicker53 in reply to ponynicker53Oct 6, 2012. 7:43 PM
Ok, I switched the positive and negative wires on the arduino, and now it rotates through the colors, however it does it all the time, the photosensor doesnt seem to turn it off. I tried switching the negative/positive orientation on it, but no change.

Also, how would you make it fade through the whole spectrum of light?
ricardouvina (author) in reply to ponynicker53Oct 7, 2012. 7:27 AM
Try to adjust the code at:
if(ambientLight>600){ // start only if the ambient light is very low

change the number 600 to a value that works for you, try to increase or decrease it.

About the spectrum of light, I'm sorry but I don't know how to make. Try to search on the web, probably there is some kind of sine function that does that.
kartikrv says: Sep 26, 2012. 8:09 PM
Hey!

First of all, this is a pretty sweet project. I'm just getting myself used to some pre-done projects before jumping into my own stuff.

My question: how would the circuit change if you dont have an ldr?

Thanks!
ricardouvina (author) in reply to kartikrvSep 27, 2012. 4:28 PM
Hi!
It's very simple, just remove the "if" function and the ambientLight variable, like this:

float RGB[3];
int redLed = 11; // red LED in Digital Pin 11 (PWM)
int greenLed = 10; // green LED in Digital Pin 10 (PWM)
int blueLed = 9; // blue LED in Digital Pin 9 (PWM)

void setup(){
pinMode(redLed,OUTPUT); // tell arduino it's an output
pinMode(greenLed,OUTPUT);// tell arduino it's an output
pinMode(blueLed,OUTPUT); // tell arduino it's an output

// set all the outputs to low
digitalWrite(redLed,LOW);
digitalWrite(greenLed,LOW);
digitalWrite(blueLed,LOW);
}

void loop(){
for (float x=0;x RGB[0]=255*abs(sin(x*(180/PI))); // calculate the brightness for the red led
RGB[1]=255*abs(sin((x+PI/3)*(180/PI))); // calculate the brightness for the green led
RGB[2]=255*abs(sin((x+(2*PI)/3)*(180/PI)));// calculate the brightness for the blue led

// write the brightness on the leds
analogWrite(redLed,RGB[0]);
analogWrite(greenLed,RGB[1]);
analogWrite(blueLed,RGB[2]);

for(int i=0;i<3;i++){
if(RGB[i]<1){
delay(100);
}
if(RGB[i]<5){
delay(50);
}
if(RGB[i]<10){
delay(10);
}
if(RGB[i]<100){
delay(5);
}
}
delay(1);
}
}

I hope it helps, thank for the comment!
xiaojiang says: Sep 20, 2012. 1:16 AM
So nice ! I was going to use it for my good friend.
ricardouvina (author) in reply to xiaojiangSep 22, 2012. 12:18 PM
I hope he likes!
geoffb37 says: Sep 9, 2012. 2:51 PM
Excellent first project for myself with the limited things that came with my uno kit.
How do you think we could say put a strobe effect in there via a switch?
Many thanks for the post !!
On all the time as i havent found near a 120K resistor yet lol.
ricardouvina (author) in reply to geoffb37Sep 9, 2012. 4:19 PM
Hi! I think that it's possible to add a strobe effect, you just have to write a function for that, and when the switch is activated you just have to call that function, if is that what you mean.
It would be something like that:
if(switch = ON){
strobe();
}
else{
moodLamp();
}


About the resistor, any other near value should work, you just have to adjust the value of the ambient light.
I hope you can do it and make an instructable.
rsusigan says: Aug 17, 2012. 7:26 AM
Great project, I will try it out tonight and let you know how it goes!
ricardouvina (author) in reply to rsusiganAug 17, 2012. 10:05 AM
ok!
rsusigan in reply to ricardouvinaAug 23, 2012. 10:27 AM
It works perfectly, thanks a lot!
powerman666 says: Aug 22, 2012. 10:45 PM
you helped so much. I have been wanting to do this! Now with your code it is possible.
ricardouvina (author) in reply to powerman666Aug 23, 2012. 6:43 AM
It's a pleasure to help!
KGuy says: Aug 17, 2012. 11:40 AM
Finally! Something that I have all the pieces to!

Nice job!
ricardouvina (author) in reply to KGuyAug 17, 2012. 5:25 PM
Thank you!
xBacon says: Aug 11, 2012. 8:17 PM
HAH I'm the 5000th view
ricardouvina (author) in reply to xBaconAug 14, 2012. 6:45 AM
Congratulations!!!
xBacon in reply to ricardouvinaAug 14, 2012. 7:21 PM
Thank you!
1-40 of 48Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!