Apple Style Light Pulsing using ATTiny and PWM

I had quite a bit of trouble getting PWM to work on the ATTiny85 for some reason, but after many trials, I finally got it working and tweaked it so it acts a lot like the sleep light that you see on so many Apple notebooks. This chip costs about $1.50, and even less if you get it in SOIC rather than 8-DIP.

You can write code in C or Assembly – I prefer C – you can make cool macros, there’s a really nice libc for AVR chips, and it’s just plain easier.  Supposedly you could code in BASIC as well, but that’s so 1985.

Anyway, I hooked up this little chip to my breadboard and USBTinyISP programmer using some wires.  It was actually really simple.  I highly recommend the programmer – it was fun to make, works perfectly, and is really convenient in Linux – very plug and play with avrdude.

The code for my program follows:

This also shows how to do some debugging with SimAVR (all that commented stuff at the top). I couldn’t quite get it to work right, but there’s some great active development going on, and help available on Freenode#simavr. I highly recommend you try it out if you experiment with raw AVR code.

Overall, I’m really happy with the AVR MCU. I think I’ll be sticking with them as time goes on.


Leave a Reply

Your email address will not be published. Required fields are marked *