Main Menu

Secondary Menu

ATtiny85 Mini RGB Mood Light!

About: I'm a big Arduino fan. I'm always looking for new and exciting things to do with electronics and Arduino. I also like video gaming on my PC and Xbox. I also ride my bike almost every day, and sometimes swim/...
More About xBacon »

I have seen RGB mood lights using Arduino, PIC, and larger AVR chips, but never one with the ATtiny85. That's why I decided to make one.

This mood light is super simple to make and all the parts can be purchased online for about $5.00 total (not including the Arduino used to program the chip).

This is a contest entry in the LED contest with Elemental LED and the Hurricane Lasers contest, so if you like it, vote!

EDIT: I have changed this instructable so that it is a NIGHT LED Mood Lamp. It now only lights up when the ambient light in the room is very low (at night with all the lights off). You do need an LDR and a 10K ohm resistor to add this part though. If you want it to not have this feature, just remove the LDR/10K resistor part and connect Analog Input 3 of the ATtiny (pin 2) straight to ground.

Step 1: How Does It Work?

The ATtiny85 only has 2 PWM pins, so obviously you can't make all 3 colors of the RGB LED fade in and out smoothly, right? Wrong.

The way I got around this was by using software PWM. This means that I can fade in and out of all 3 colors using any of the pins on the ATtiny.

How software PWM works is by setting the pin HIGH and then LOW at different rates so that the LED looks like it's dimming. This is called Persistence of Vision or POV (for more on POV, see my instructable here). The LED blinks so rapidly that the human eye can't detect that it is flashing at all, and it sees instead that the LED appears to be dimming.

you could take the IF...ELSE loop out of the program.If you do not know how to do that, well you could replace the sensor by a wire bridge or leave it open, depending on how it is wirdIn the program you see that if the value read from the sensor is greater or equal than 201, the lights shld go out.As I presume the lights shld go out when it is light ( low resistance of LDR) and on when it is dark (high resistance of LDR), I guess just omitting the sensor would do the trick.

Great article.Though you are right on the software PWM, there is some discussion on wether it has 2 or 3 PWM outputs.Supposedly it has 3, all addressable from inside the IDEIC leg 6 (PB1),IC leg 5 (PB0), IC leg 3 (PB4), Supposedly, strictly speaking IC leg 2 (D3/PB3) is also capable of PWM, but internally it shares the same timer used on leg 3.I didnt try it myself, but that is what I have been reading. Some discussion going on here:

actually, I built this and ran it using my original code from my arduino sketch, apparently there is a hush hush third PWM that's buggy but functional on the AtTiny, and the code eliminates functions and uses for().