The first thing we've got to do on the way to creating our Ghetto pixel, is to give our little computer (the ATTiny45 uC) some instructions. This is called 'Firmware' and you load it onto the chip using a programmer. Hang in there, I explain all in a minute. First I've got to make an introduction. You see, I'm not nearly clever enough to do any real embedded systems programming, so I'd like to introduce you to a project that (er?) is... CYZ_RGB
. Started by Matteo Caprari and more recently extended by John Laur, CYZ_RGB is a fairly direct replacement for the official BlinkM firmware. Of course, you don't have to run it on official blinkM hardware, you can load it onto any compatible uC and connect up a LED.
If you head over to the CYZ_RGB google code page, you'll be able to download the firmware
from the project. There are two different configurations, Master and Slave, I'm not even sure if Master works, or what it does, I use the slave builds which are fine for my needs, with one exception!
I think it is assumed that you will be running CYZ_RGB on the official BlinkM hardware, or some kind of direct clone of it, and therefore the code is written to support Common Cathode RGB LEDs (which BlinkM's use). I have a surplus of Common Anode RGB LEDs, so I had to make a small change to the code to support this.
If you care: in the cyz/io.h file, where the bits are set to turn on, or off specific ports, I've swapped the bit assignment. When a colour comes on in the code, the pin goes low, so that it can sink current from the common anode.
I've included my common anode Hex file below, in case it's useful. Other than the change above, it's identical to the latest build of the slave config on the google code page.
Now you have the .hex file that you are going to burn onto your uC, so lets talk about programmers and programming. There are many great instructables on the subject, but my favourite and the one that got me started with AVR's is this one, The Ghetto Development Environment
. I use the same programmer, the USBtinyISP from Adafruit
, and it's awesome. I started out with a home made target board (cradle) but have now bought a tiny25/45/85 programmer board from TinkerStore
, which is just made of awesome. You would be fine with a home made cradle, or just programming in a breadboard.
Follow the instructions on the Ghetto Development Environment for loading code onto the chips, but note that you are using an ATtiny45, so your avrdude command needs to reflect that part (t45). Obviously, you also specify the name of the CYZ_RGB .hex file that you are using too.
You should also be aware of fuses. These are settings in the chips that change how they behave. I use a piece of (windows) software called Burn-O-Mat from AVR8 to check my fuse settings (you can also use it as a GUI for avrdude). It seems that from the factory, my Tiny45's have the "Clock Divide by Eight" fuse already set, this needs to be unset for the chip to run fast enough for smooth fades. One chip i was using also had the ability to store data in EEPROM disabled, so I had to toggle that fuse to (you probably won't need to do that)
Now you've read the GDE instructable, the following line...
avrdude -c usbtiny -p t45-U flash:w:cyzrgb_slave_CA.hex
...shouldn't freak you out. If you are a real keenie, you've probably all ready done it, If not, go ahead and program your chip now.
Assuming there are no errors in the output, you should be good to go.
While we are in the programming mood, you should grab your Arduino as we've got to load a sketch onto that too. The Arduino is going to be used to control the Ghetto Pixels, and forms a bridge between them and your computer. To start with, we can use the BlinkM communicator sketch for testing, but in time you'll probably want to write your own more suited to your application. The BlinkM communicator
sketch is here
, and you should load it onto your Arduino now. While you are on the BlinkM site, download the multitrack sequencer
, you'll need that for testing too.
With your freshly programmed Chip and your Arduino by your side, it's time to get it on with Das Blinkenlights