Right now, I'd like to give out mad props to ThingM and todbot, without whom there would be no BlinkM, and the world (or at least youtube) would be a much less colourful place. The aim of this instructable is not to take business away from ThingM, in almost all cases I would encourage you to buy a blinkM or two if you need them in your project, but there are some reasons why it's good to have alternatives and these are the ones I'm thinking of:
- You need a lot of BlinkM's and can't afford to buy as many as you might need
- You have all the bits needed lying around, and loads of free time and solder to make them
- You like a bit of a challenge.
- The form factor of the BlinkM doesn't meet your projects requirements (ThingM also do a variant called the MinM)
- You are _really_ hung up about open source and want to stick it to the man.
So, The aims of this instructable will be to:
- Introduce the reader to CYZ_RGB, an open source RGB Pixel firmware based on BlinkM
- Show how to program the firmware onto a suitable Microcontroler
- Suggest a way for building the pixel, that doesn't use Proto or PCB boards
- Show how to use the Pixel.
Lets get started, gather your stuff.
Step 1: What you are going to need...
The parts list (BoM) for one Ghetto pixel looks like:
- 1x RGB LED (RapidOnline or ebay)
- 1x Atmel ATTiny45 (or tiny 44 or 85, ) (RapidOnline or ebay )
- 3x Resistors as per specifications of your LED data sheet (RadioShack / Maplin / Rapid / or similar to these [ebay]) probably 1/2 watt or less if you can find them. SMD if you are PRO ;)
- Some wire to connect the Pixel to your controller, and to string pixels together if you have more than one
Notes on the parts:
I would recommend getting an RGB led in a single plastic housing. It would be possible to do this with three separate LEDs, but it would be more of a challenge to mix the colours well. You must avoid the RGB led's that you buy on ebay that are described as 'Slow Flash', 'Fast Flash', or 'Fade' as these have there own uC's built in, and while pretty, allow us no control over the colour. You can get 'manual control' RGB LED's that look like traditional 5mm domed LEDS, but with 4 or 6 legs, but these don't tend to be very bright. I would recommend getting LED's that are labled 'SuperFlux' or 'Piranha'. These are small square RGB LED's with four pins, and can be surprisingly bright for their size.
You also have a choice to make on Common Anode, or Common Cathode variants. All four pin RGB LEDs are made up of three individual 'dies' all in the same plastic housing, each 'die' gives off one colour, either Red, Green or Blue. Each 'die' has a positive (anode) and negative (cathode) supply. A common Anode LED has all three anodes linked together, and the three cathodes are separate. A Common Cathode LED has the opposite configuration, All three Cathode are linked together and the anode's are separate. The firmware that we are going to be using makes use of Common Cathode LED's, and it's probably best that you use those. However, I had a pile of superflux Common Anode LEDs, so I've modified the CYZ_RGB firmware to use common anode. I'll talk about this later, but i've only compiled and tested this modification on a ATTiny45 uC, so if you are planning on using any other uC I'd push you towards common Cathode LEDs.
Phew! Are you still with me?
The uC is the brains behind the Pixel. We tell it what colour we want, and it controls the LED. For this project, I'm going to suggest you use the Atmel ATTiny45, because that's what I used, and it's fairly easy to get hold of. The CYZ_RGB project also supports the ATTiny 44 and 85, and other 4k+ uC's in the ATTiny range might work, It depends on how much time you want to put in modifying the code. I was lucky, I found the ATtiny45 on sale at Rapid Electronics (in the UK) for 90p each (about $1.50 US) so snapped up 10.
The resistors are used to limit the current that passes through each 'die' of the RGB LED. When you buy the LED's you should get a datasheet that shows various details on the electrical characteristics of the LED, such as the forward voltage and current for each colour. You will need to put these into a LED resistor calculator along with the supply voltage (I would recommend 5v, but it depends on your application). The results will probably end up around the 100 Ohm region, with the value for the red LED being a bit higher. At this point I'd like everyone who knows anything at all about electronics to move onto the next section while I talk for a second about how I do things. Please don't shoot me for what i'm about to say.
LEDs and uC's are cheep. You are going to blowup/melt/fry a few of them. So buy extra. I've never been SuperMathsMan and I don't have a lot of patience when it comes to numbers, I tend to design circuits by trial and error. A current limiting resistor on an LED is there to stop the LED sucking so much current that it melts itself and/or the pin of the uC it's connected to. But it's a balancing act, if you use a resistor that is too high in value, your LED is going to be dimmer than it could be, because you are preventing enough current getting to it and If you use a resistor that is too low in value, your LED might be really bright, but it will burn it's self out and probably take the uC with it. Start of with what ever the LED calculator tells you to use, and then see if using a slightly less resistive resistor makes the LED brighter. leave the LED on for a while with the lower value resistor in, and touch the uC with the back of your hand or the top of a finger to see if it's getting hot, if it is, use a higher value resistor. If stuff melts or you let the smoke out, then smile and recognise that you've found the lower limits of the resistor you can use. It's all part of the fun.
Well done for making it this far, but unfortunately, it's not quite over, there are some tools you are going to need.
- Breadboard and breadboard wire
- Arduino - See note below.
- (Optional) Programmer for flashing hex files onto the uC (I use this one from Adafruit)
- Soldering Iron (a good one), Solder, tip cleaner, solder sucker, wick etc...
- Helping hands, or desk clamp thingy
- Good Lighting
You are going to need an Arduino for a couple of different things. It's main job will be to control the chain of pixels you are going to build (why stop building at one?) but it can now also be used to flash firmware onto the chips using ArduinoISP, replacing the need for a dedicated chip programmer. I don't use ArduinoISP, and it does sound like it's got a few issues it needs to work out before it's allowed to wear the awesome badge. I don't think it works yet with the Arduino Uno, and if you have an arduino that uses a Mega328 chip, you need to use a resistor to change the auto reset function. However it's a good option if you don't have a programmer.
Lets move on.. It's time to program some chips!