103Views10Replies

Author Options:

How do I make 3 LEDs alternately fade for a night light? Answered

I'm trying to make a night light for my little sister and thought it would be cool if I could make the leds fade alternatively. basically  the red would get bright and then dim and then the green would get bright and then dim and lastly the blue would get bright and then dim and then the cycle would start again. I found some code that allows me to brighten and dim a single LED but I couldn't figure out how to alternate three of them. Could you help me please : )

Discussions

0
None
steveastrouk

Best Answer 2 years ago

Take your code that does it with one LED. You'll see a line near the top that says LED1 analogout(A11) or something like that.

You need to create three lines LEDred, LEDgreen and LEDblue.

For a start, there'll be a line that says something like LED1=counter.

Add more lines like LEDred=counter; LEDblue=255-counter and see what happens.

Find the code that loops the led fade up and down continuously. There'll be somehing like a "WHILE 1==1" and a { bracket.

Look for the mating } bracket.

Copy all the previous code inside the "WHILE" {} twice more.

Change the names of the LED1 to LEDred, LEDblue, LEDgreen

0
None
inconceivable1

2 years ago

ok guys thanks so much! after around 5 hours i figured out a way to do it using the while function. apparently all i needed was dedication and time. Thanks so much for awnsering though!

0
None
iceng

2 years ago

A set of sequenced 555 by a 017 can do it. Especially since you don't mention an arduino or describe the code functionality... But your skill set needs soldering for enhancing glory...

0
None
inconceivable1iceng

Answer 2 years ago

i don't know what those things are sorry I'm just begining

0
None
icenginconceivable1

Answer 2 years ago

Most people start with an LED and a simple 8-pin LM555cn IC timer...

The (first pic) is a circuit schematic of the how to wire the 6 components..

IC => Integrated-Circuit (second pic) and only then go on to use a uP...

micro-Processor => uP uses software, which you call code...

steveastrouk

is giving you excellent advice.. You do need to understand a little software program writing to create the specialized code you are asking for to accomplish your sisters night light...

NoneLM555-PINS.jpg
0
None
inconceivable1

2 years ago

all I have is an arduino uno and the beginner's kit I need to know the code nessisary to alternate the LEDs fading

0
None
Downunder35m

2 years ago

For a few bucks you can get exactly that plus a rotating platform (if you want).
Just check Ebay for LED crystal lights.
Some even come solar powered.

0
None
Downunder35mDownunder35m

Answer 2 years ago

Or get a cheap LED controller and add your own LED's with a resistor to match 12V.
Also available with 44 keys and more function for a few cents more.
You can't make it yourself for that price LOL

0
None
steveastrouk

2 years ago

blue lights keep people awake.....