A little while ago, I picked up some diffused RGB LEDs intending to use one of them as a status indicator on the robot. Had never got around to it – plus it would need 3 pins from the micro-controller which I didn’t have available when I bought them. There was always the option of the BlinkM, an I2C controlled RGB LED with an on-board ATtiny45 micro-controller – they are a bit on the pricey side though.
The other night, whilst looking at something or other on instructables.com I saw this tutorial in the sidebar. Since I’d picked up 25 x ATtiny45 for peanuts from digi-key before Xmas it seemed like a fun thing to attempt (“peanuts” was £57 for 25 x tiny45, 25 x tiny85 and 25 x mega328 – add on the £16 customs charges and that was 75 microcontrollers for under £75 – not bad when you’ll struggle to get tiny45 under £1 and can easily pay £3-4 for a mega328).
I’m obviously not going to be etching any circuit boards so It looked like this was a job for Adafruit quarter-size perma-proto board. I put one together fairly quickly:
It really was a fairly routine “build”. The tiny45s have power and ground on opposite corners, I just ran extra power ground alongside so I could add 0.1uF decoupling capacitors. It looks a bit messy but using the resistors to connect the RGB LED pins to the tiny45 simplifies things a lot.
The Attiny45s need configuring to run at 8MHz off their internal oscillator, I did this via ArduinoISP using a “shield” assembled from a Proto-Pic arduino breadboard shield.
The programmer board has no de-coupling capacitors and no 10K pull-up resistor on the reset pin. I haven’t found any occasion where they’ve been needed yet – having this sat on top of an Arduino Uno probably isn’t the most electrically challenging environment though. I’m hoping to squeeze a 20-pin IC socket onto here so this can also program ATtiny2313 chips which I have and haven’t done anything with yet.
Once the tiny45s have had their fuses set (it’s “Upload Bootloader” in the Arduino IDE – but there is no bootloader on these so all it does is set the fuses) it’s time to program them with the CYZ_RGB firmware. In my case that was just:
avrdude -c avrisp -p t45 -P /dev/ttyACM0 -b 19200 -U flash:w:cyz_rgb_slave_attiny45.hex:i -v
So I built the first two and tested them and then decided to make 4 more to use up the 6 RGB LEDs that I had. I tried to be organised and assemble all the bits needed before starting:
I made all the link wires up front rather than having to keep interrupting the soldering. That’s about all that’s needed. There are also resistors for the LEDs in the lid of that Altoids tin – I didn’t have enough of the 160Ohm ones I used for the first two boards so they’re 190 or 220 on these four. Initially, I thought that different values made a difference to the LED output – after playing around with them I figured out that I couldn’t really tell the difference.
They’re simple to put together really…
Apply solder 🙂
As usual, you just keep working though adding the smaller, thinner components until you finish with the LED.
That’s the 6 of them all ready for plugging in and playing with. You can use the BlinkM arduino software with them which lets you set I2C addresses and play with colour fading etc. I marked them with the 7-bit I2C address, in binary 🙂
Here’s a cruddy video of them running a Cylon pattern followed by simply cycling through some colours…
So, I’ve got a supply of these ready to add to any project that uses I2C. For the robot I could upload whatever sequence is required over I2C and then just tell it to play that sequence without having to keep wiggling pins. Haven’t explored the CYZ_RGB firmware yet so don’t know if I can upload multiple “scripts” and then just tell the board which one to play when I need to signal something.
I reckon these cost about £3.50 each with that being about £1.65 for the perma-proto board, 50p for the Attiny45 and £1.15 for the LED – that leaves 20p for resistors, headers and cheap 8-pin sockets. Not too bad really, if you used proto-board or solder the LED directly to resistors and on to the ATtiny (as one instructable does) then you could eliminate a fair chunk of that cost.