I want to create night lamp that changes color
I need to be able to turn it on and off remotely (from my bed actually)
I might want another version without remote to cheer my night trip to toilet
I'm in love with Attiny85 mcu and I want to do something fun with it
I want to practice in designing and assembling simple PCBs to gain experience for bigger projects
I decided to assemble version that is possible to switch on and off remotely using RF433 radio module. Although module itself is building and working fine with Attiny85, it is using Timer0, therefore blocking 2 pwms. Timer0 works in CTC mode, so basically it is always 50% pwm (sort of) and i can only change frequency by adjusting radio channel speed. So trick here is
RF library finds register OCRA value in combination with prescaler for which Timer0 overflow will happen once per bit sent, therefore I can find radio speed, so OCRA value will be close to 255 (I found it to be 254 actually, which is close enough)
When i have Timer0 running in CTC mode from 0 to OCRA i can set OCRB register value to any value between 0 and OCRA and by hooking up interrupts to OCRB match and timer overflow I'm able to switch led on and off in PWM manner
This trick not working brilliantly for small values, but for my case it is good enough
I used this article for technical inspiration. Basically Attiny85 has 2 timers, providing 2 pwms each. Unfortunately pins for those pwms overlapping, so getting 4-th pwm is tricky. But 3 is enough for me, so that works quite ok.
I used smd led for this one (KY-009 module), but actually it is not brilliant, it is not very powerfull and colors are not very bright.