How can I fade or color change an LED over the span of several hours?

I'm interested in having an LED go from Green to Yellow to Red over the span of 2 days.  I know this will probably run the battery out so I was thinking of using an optoelectric sensor so it only lights when exposed to dark areas.  Any thoughts?

sort by: active | newest | oldest
AndyGadget6 years ago
An interesting requirement - What's it for?
A little microcontroller connected to an LDR and a red/green LED would be the best thing to do this :- Connect the LED between 2 pins outputting a complimentary square wave and change the mark-space ratio to vary from 100% on one pin to 100% on the other which would give the range from green through yellow to red over the time you want using nested delay loops.
To save power you'd use the low power modes of the controller (taking less than a milliamp) and have it wake every few seconds to check the LDR to see if it needed to power up the LEDs.
I'd do this with a Picaxe 08m, but everyone has their favourite microcontroller family. 
lancewill (author) 6 years ago
Thanks everyone for your replies!
yokozuna6 years ago
I'm not sure they make RYG LEDs, but I do know the make RGB LEDs. If you just need a single LED, a 9V battery with a resistor in place can likely power this over a 48 hour period, although it may fade a little towards the end. You can always add another battery and make sure it lasts long enough too.
R+G = Y ;)
janw6 years ago
I'd use a small microcontroller (attiny or so) with an LDR indeed and a slow changing PWM to change the colours
They make bi-color LEDs - red and green in one package, so you need all green on, 1/2 green 1/2 red, all red on.