Ghetto Pixels - Building an open source BlinkM

Ghetto Pixels - Building an open source BlinkM
Unless you've been living under a digital rock for the last few years, or just simply aren't interested in flashing lights, you'll already know about the awesomeness that is the BlinkM from ThingM. It's a very small PCB featuring a high power LED that responds very easily and cleanly to commands you give it. Devices like BlinkM's are often referred to as LED Pixels, because they can be linked together in fairly long chains, but still remain individually addressable (you can set the colour of each one to be different).

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.
For me, this project came about because of the first three in the above list. I needed 7 pixels, which is a few more blinkM's than my budget can stretch too, I had a bunch of parts already lying around and lot of spare solder (although the free time bit is always an issue) and yes, I'm a sucker for the impractical.  "Why buy something when you can spend hours and hours of your precious free time trying to work out how it's done and failing multiple times before finally suceeding, sort of, and ending up with something that is nearly, but not quite as good as you can buy."  I probably need to readjust my priorities in life.


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.
From now on I'm going to stop using the name BlinkM to describe the product of this instructable, it's just not fair to ThingM. What I'm building isn't as good as a BlinkM, and I don't want people to think that the BlinkM is less awesome than it actually is, but it's been useful as an introduction because everyone is so familiar with the concept. From now on, I'm in the Ghetto Pixel building business.

Lets get started, gather your stuff.
 
Remove these adsRemove these ads by Signing Up
 

Step 1What you are going to need...

What you are going to need...
The key components for a Ghetto pixel are an LED, a Microcontroller, and some current limiting resistors.  It doesn't get much more complicated than that.  I'm going to refer to the Microcontroller as a 'uC' from now on and if I talk about "the LED" I am probably referring to an RGB led.

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:

LED
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?

Microcontroler (uC)
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. 

Resistors
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
A note on the Arduino.

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!
« Previous StepDownload PDFView All StepsNext Step »
35 comments
Nov 16, 2011. 12:13 PMMister_A says:
Hi,

I'm trying to build one of these but I try to use it with my own arduino Sketch. I connect the RGB pins to pin 1,3,4 on my ATTINY45. But on Pin 3 and 4 the led simply blinks instead of fading on or of. On pin 1 the LED fades in and out like it should. If I have read the specs for the ATTINY45 correctly, only pin 0 and 1 support PWM. Is this the reason? But how does it work with this blinkm firmware then? They don't use PWM to fade the RGB leds in and out?

My source for my arduino sketch:
int redPin = 1; // Red LED,
int greenPin = 3; // Green LED,
int bluePin = 4; // Blue LED,

// Program variables
int redVal = 255; // Variables to store the values to send to the pins
int greenVal = 1; // Initial values are Red full, Green and Blue off
int blueVal = 1;
int i = 0; // Loop counter
int wait = 15; // 50ms (.05 second) delay; shorten for faster fades
int DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup()
{
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);


}

// Main program
void loop()
{
i += 1; // Increment counter
if (i < 255) // First phase of fades
{
redVal -= 1; // Red down
greenVal += 1; // Green up
blueVal = 1; // Blue low
}
else if (i < 509) // Second phase of fades
{
redVal = 1; // Red low
greenVal -= 1; // Green down
blueVal += 1; // Blue up
}
else if (i < 763) // Third phase of fades
{
redVal += 1; // Red up
greenVal = 1; // Green lo2
blueVal -= 1; // Blue down
}
else // Re-set the counter, and start the fades again
{
i = 1;
}

// we do "255-redVal" instead of just "redVal" because the
// LEDs are hooked up to +5V instead of Gnd
analogWrite(redPin, 255 - redVal); // Write current values to LED pins
analogWrite(greenPin, 255 - greenVal);
analogWrite(bluePin, 255 - blueVal);


delay(wait); // Pause for 'wait' milliseconds before resuming the loop
}
Nov 15, 2011. 12:30 AMcorrupt85 says:
Hi,

I would just liek toknow if this could be applied in the same manner to a Luxeon III Star Led like this one:

http://www.seeedstudio.com/warehouse/index.php?main_page=product_info&products_id=194.

i am kind of new to the whole electronics/led world and i've kind of hit a wall here.

im trying to get together an RGB LED preferably a luxeon or cree with super high light output and control the color sequences.

please advise,

Much appreciated.
Nov 13, 2011. 2:41 PMscottinnh says:
Hi Jim,

Thanks. If by "-ve line from the tiny85" you mean PIN4 (GND) tied to the LED cathode, it's not. They're both tied to a common ground, but not each other.

And yes that's what you meant, I'm not sure exactly what you mean in terms of specifics... if I wire PIN4 to LED cathode, they'll connect but there won't be anywhere for GND to flow to.

Or maybe you meant something else by '-ve'?
Nov 13, 2011. 8:56 PMscottinnh says:
OH you're KIDDING me, Arduino IDE.

The Arduino IDE defaults to 9600 baud. The ThinkM script initializes serial to 19200 baud. Apparently the Arduino IDE can't detect this, self-adjust, or warn and so the text is garbled.. once I set the serial monitor to 19.2 I can read the output fine. Hopefully this helps someone else.

The LED still isn't doing anything, but at least I can start debugging it. Maybe I missed a setup step at the end. Feeling better at least :-)


Thanks

Nov 13, 2011. 8:36 PMscottinnh says:
Hmm..

Serial console works perfect if I base a simple sketch around:
Serial.println("Hello World");

Let me ask this.. Are you using 0022 IDE?

I see in the BlinkMCommunicator sketch code, there have been past issues with it not working on a Arduino IDE release (there is a comment of 0012 incompatibility fixes in blinkM_funcs.h). It might be that again, or something else I just don't see.

Nov 13, 2011. 12:55 PMscottinnh says:
I took the suggestion to use common-cathode RGBs, and followed this tutorial, but I get no joy. Something's wrong obviously, but not sure what. Could a second set of eyes spot the problem?

The Arduino Uno has BlinkMCommunicator loaded. No errors uploading it. When I enable DEBUG in the sketch and open the serial console, each time I rese the Arduino it prints this junk: ¬Ö„ÖoÈg÷ãÃOþ

The ATtiny85 uses the type 85 firmware for CYZ_RGB. No errors when flashing it.

Arduino:
Analog IN A4 -> ATtiny85 PB0/PIN 5
Analog IN A5 -> ATtiny PB2/PIN 7
5V -> ATtiny Vcc/PIN8
GND ->ATtiny GND/PIN4

ATtiny85:
PB5/PIN1 -> empty
PB3/PIN 2 -> LED anode A
PB4/PIN3 -> LED anode B
GND/PIN4 -> Uno GND
PB0/PIN5 -> Uno A4
PB1/PIN6 -> LED anode C
PB2/PIN7 -> Uno A5
VCC/PIN8 -> Uno 5V

I saw in one comment that the schematic should be exactly the same if you use common anode or common cathode. So I did not change anything.

The LED is good.. if I move the 150ohm resistor to 5V, that color lights up.
At this point I can't tell if it's an issue with the controller on the Uno, my wiring, or an issue on the ATtiny.
Nov 13, 2011. 12:56 PMscottinnh says:
Attached are some images (having trouble uploading them using Google Chrome.. second try..)
attiny-zoomout.jpgattiny-zoom.jpg
Oct 14, 2011. 9:22 AMmrtsunami92 says:
Hey all,
i build 10 "BLinkm clones" aka Ghettopixels.
now i want to place them in my floor and i want to use cat5 cable to connect them... will this work ? i got about 15meters length...

Thanks for upcomming answers
Aug 19, 2011. 3:00 AMcorrupt85 says:
Hi, first of all congratulations and thanks for such a great tutorial!!!

My question is regarding a PCB boards. i see on this link (http://sjalbers.nl/Atmel/BlinkM/BlinkM.htm) that he has his mounted on PCB's. Ques: has he made these him self? if so how?? i really want to make some of these..

thanks

Jul 26, 2011. 4:23 AMmrtsunami92 says:
Hey,
im using piranha common cathode LEDs, i can`t get it working :(
please help me
greets from germany.
Jul 28, 2011. 11:57 AMmrtsunami92 says:
what about the schematics ? still same ?
connect LED to PB 3/4/1 ? with resistors of course... cant get it workin :(

greets from germany!
Jul 30, 2011. 10:04 AMmrtsunami92 says:
Hey,
AVR Studio 4 isn`t recognizing my USB tiny ISP.... what can i do ??? oO
if i flash the .hex via avrdude it gives me a "success" and a led lights up...
rgb led is connected to GND -- common cathode and the R, G,B with a resistor to PB 1/3/4

in BLinkM Sequencer, at scan I2C bus nothing is shown

help please!

greets from germany ^^
Jul 31, 2011. 6:57 AMmrtsunami92 says:
Sorry,
all working now :D Thanks a lot :D
but tell me, do i always have to connect ghettopixels--arduino--pc ??


greets
Jun 22, 2011. 1:51 PMscottinnh says:
Nice. And you made h-a-d. :-)

I just ordered most of the parts I needed for this... going to start by cloning 10.


For folks that appreciate this, there was another clone attempt of BlinkM someone did recently. It too is a nice effort (and includes a batch of custom PCBs): http://sjalbers.nl/Atmel/BlinkM/BlinkM.htm

Blinky stuff == AWESOME
Jul 29, 2011. 12:40 PMscottinnh says:
I should point out for readers - this article text does not specify if the ATTiny45 should be 10PU or 20PU model.

I expect the 10PU is all that is needed (and if you notice, the author's bit.ly links actually link the 10PU model).

However, Mouser charges much less for the 20PU model ($1.87) vs the 10PU model ($2.30).

There may be other differences between the 10PU and the 20PU, however I can not qualify that (read the spec sheet).

Would be interesting to hear from some readers who made this..

Jul 15, 2011. 3:31 PMbeverageexpert says:
great project. Couple of questions
!st how do I stop the flicker? some colors are solid and others flicker alot

I am using your firmware for the common anode and I finally got everything working alright. I am using the sequencer and everything works except when In upload to the blinkm. It doesnt seem to be holding the program. It just turns a solid color. Have you had this issue?

thanks
bryan
Jun 23, 2011. 3:52 PMsydkahn says:
great work - very complete - and with that little extra most people need to be successful doing someone else's project.

Wonder if a large surface mount type resistors would make it a little more compact.
Jun 22, 2011. 10:47 PMmacce says:
Would it be possible to skip the resistors completely and just rely on a small duty cycle and high enough PWM frequency to avoid flicker?
Jun 22, 2011. 1:37 PMstonechild says:
I really like your idea. I looked into a DIY ShiftBrite, but it seemed too difficult and didn't save much $$. Question: couldn't you turn the chips over to get the LEDs closer?
Jun 20, 2011. 10:31 AMCabe says:
"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."

Or it was faulty, congratulations you are a destructive testing expert :)
Jun 20, 2011. 9:49 AMDJJules says:
Nice Project! Well done.

Jules
Jun 19, 2011. 7:16 PMFuzzy-Wobble says:
yes yes yes.
im going to be building these very soon.

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
13
Followers
3
Author:jimthree(jimblackhurst.com)
@jimthree