The RGB LED Ring is as a DIY SMD kit! Honestly, ignore the next two paragraphs :-)
Well as of next Monday 18:00 CET to be honest (May 17th 2010). I’ve already added it to zen-cart, but it’s still marked as sold out. This morning FedEx didn’t manage to deliver the shipment from Mouser containing the vital ATmega168 chips — and they didn’t even leave a note :-(
I haven’t done all of the math yet, but basically I’ll be giving these away at cost. The fun is in the making and releasing. I couldn’t live on selling these things anyway. …1 or 2 days later… I’ve done the math and ‘at cost’ is 9.35€ + shipping.
It has been upgraded to version 1.21 and now comes with proper LED ordering, fully functional auto-reset and last but not least an onboard ultra low drop voltage regulator. You can supply it with 4 to 12V DC and it will work just fine. No costly boost converter for 5V is required anymore. The voltage regulator is very powerful and can drive more than just this little board. If other parts of your project should need 5V as well, you can use it to feed power to them. It should be good enough to drive an Arduino board and a few standard LEDs.
You should feel at home with soldering SMD parts of sizes 0805 and larger. If you haven’t completed any SMD projects before, better watch a few tutorials first. It is not difficult as such, but you’re likely to kill the SMD LEDs without “enough” practice – and they don’t come cheap. Nowadays taking apart broken devices is a good and cheap source for SMD practice material!
To get started you’ll need an AVR programmer (usbtiny, AVR ISP MKII …). Once you’ve flashed the Arduino bootloader, I recommend using an FTDI adapter such as the Moderndevice BUB I or the FTDI Basic Breakout – 5V for convenience.
I can recommend the USBtinyISP or the Pocket AVR Programmer. Both cost about 15$-25$ and are compatible with AVRDUDE and work on Linux and MAC OS (and windoze if you have that). You can also easily use the Arduino IDE with both of them.
1. Identify all parts
2. Solder it
2.1 Paying special attention to the RGB LEDs
2.2 Soldering tips
3. Flash it
3.1 Flash it – an update
4. Be creative
4.1 Arduino pin names
4.2 Battery Power
4.3 I²C / 2-Wire
4.4 Voltage regulator
5. Hacks, Mods
5.1 More light hack
5.2 Extremely more light hack
6. Upload code
6.1 Adding the board to the Arduino-IDE
6.2 Upload code with an Arduino board (ArduinoISP)
6.3 Upload code with an FTDI adapter
7. Share your projects
If you have any trouble, please use the forum!
1x PCB (big round orange object)
1x 10k Ohm 0805 (R4)
1x 91 Ohm 0805 (RED, R2)
1x 390 Ohm 0805 (GREEN, R3)
1x 110 Ohm 0805 (BLUE, R1)
2x 10µF, 16V, tantalum, polarized, A3216
1x 10µF, 25V, ceramic, X5R, 1206
2x 100nF, 50V, ceramic, X7R, 0805
1x TS 2940 CW-5.0, voltage regulator, SOT-223
1x anti static bag
2x 10×1 female header (need cutting to size)
2x 3×2 male header
1x 6×1 male header
1x 3×1 male header
1x Atmega168-AU, TQFP-32 7×7
4x low profile jumper h=4mm
8x RGB LEDs PLCC6 5050 (ebay: JELEDHK, green very! efficient, R: 1.76V, G: 2.34V, B: 2.52V)
The single biggest and most obvious component is the printed circuit board. Its orange color will make it stick out quite nicely.
The 8 RGB LEDs are easily recognized, as they’re white. The ATmega168 microcontroller sits like a fat black spider in its web. Both components require proper orientation and have orientation marks (dots, notches…).
The remaining components are all on the back side of the board.
The brownish parts are unpolarized ceramic capacitors (C1, C2, C3). As long as they’re put to the right spot, orientation doesn’t matter. The black components are resistors, right spot required, orientation doesn’t matter (R1-R4). The somewhat larger and 4 legged IC is a low drop 5V voltage regulator and only fits in one orientation. The orange parts with the bar are polarized tantalum capacitors. They will blow up if orientation is wrong. The bar points to the anode (+). All the rest is just headers and jumpers. The 10pin female headers need to be cut to size before they fit. It is quite easy with a good and sturdy wire cutter. Take a look at the images in the soldering section.
If there are any missing parts, please let me know.
Be sure to use plenty of flux. It is imperative that you keep soldering time and temperature at an absolute minimum. The resistors, ceramic capacitors and, to some degree, the ATmega168 are quite forgiving, but the tantalum capacitors and especially the RGB LEDs are easily damaged terminally!
There is no strict order for soldering, but I suggest putting on the ATmega168 as the first part and then continue with the 8 RGB LEDs. Then take care of the voltage regulator. The remaining resistors and capacitors go on as you please. The headers should be put on as the very last parts to avoid interference and burnt plastic.
Correct orientation of critical parts:
- The bar on the tantalum capacitors (C4, C5) must point to the (+) mark on the PCB
- The orientation notch on the RGB LEDs (D1-D8) must point to the center of the PCB
- The orientation dot on the ATmega chip must match with the dot on the PCB
How to safely solder and test the RGB LEDs:
Due to a last minute change of the RGB LEDs, the silkscreen on the PCB is incorrect! Please assemble the LEDs as shown in the video.
As mentioned before these RGB LEDs don’t particularly like heat. Especially one pad of the green LED, the smallest one, overheats easily. In the picture below it is the middle pad at the bottom.
For this pad I advise extreme caution. If you have an adjustable soldering station (which I highly recommend), set the temperature to 240°C and you’ll be fine with Sn60Pb40 solder. Anything above that is likely to kill the LEDs. If you have a multimeter check if the LED works after having soldered the middle pads (top and bottom). Don’t use this pad for initial tacking! Use any other one, but not this one.
A damaged LED looks like this:
Replacing the LED is the only way to ‘fix’ it.
As you should know by now, always keep the tip clean and shiny. Use flux. If you have an adjustable soldering station, don’t turn it too high. This will make the tip last longer, less black stuff will accumulate and the flux won’t boil off as quickly. Always make sure you touch the parts and pads long enough to make the solder flow properly to all spots. For this kit I’ve used these temperatures and Sn60Pb40 solder: 240°C for the RGB LEDs and the small parts including the ATmega chip. You’ll have to touch the LEDs’ pads a bit longer to make the solder flow everywhere, but at least the darn things won’t melt. 280°C for all the headers and the voltage regulator, as there’s much more copper to heat up.
Your first step will be to make sure the 4 jumpers are placed correctly. For now it is recommended to keep the VSEL jumper in its default position, which is next to the mark on the PCB. Due to it being a low drop regulator, this will work in most cases. If you know exactly what you’re doing, do as you please.
The ISP_E jumpers must be removed for ISP programming, as the pins are shared with the LEDs. Once the bootloader has been flashed you can put them back and won’t have to touch them anymore. Pin1 of your programmer’s cable will be marked by a red wire and must line up with the arrow mark on the PCB.
* ! DO NOT USE THE ARDUINO IDE FOR BURNING THE BOOTLOADER
* ! IT WILL USE THE WRONG FUSE SETTINGS AND BRICK THE BOARD
* If you use an Arduino bootloader, I recommend the "ATmegaBOOT_168_pro_8MHz.hex".
avrdude -c usbtiny -p atmega168 -P usb -b 115200 -e -u -U lock:w:0x3f:m -U efuse:w:0x00:m -U hfuse:w:0xDD:m -U lfuse:w:0xE2:m
avrdude -c usbtiny -p atmega168 -B 10 -P usb -b 115200 -U flash:w:ATmegaBOOT_168_pro_8MHz.hex -U lock:w:0x0f:m
Make sure to follow these instructions. It is extremely critical that the FUSE settings are correct, as a bricked chip requires quite some effort to be revived. The bootloader hexfile comes with the Arduino software and can be found in this folder: “/arduino-0018/hardware/arduino/bootloaders/atmega”.
As of now, all boards ordered as ‘assembled’ come preloaded with a short demo + ‘optiboot’. You’ll find a combined .hex file in the code repository. The fuse settings for this bootloader are different as well. For details, please have a look at Adding the board to the Arduino-IDE. For tinkerers: the correct fuse settings can be found in ‘boards.txt.modif’, which is in the code repository as well. Just download the latest .zip snapshot.
For starters I recommend using the Arduino IDE! You should choose the ‘Arduino Pro or Pro Mini (3.3V, 8MHz) w/ ATmega168’ in the boards menu. This makes sure your code is compiled with the correct CPU frequency settings. Demo code for grabs. You’ll find all design files in KICAD format (including schematic as PDF and Gerger files for easy reproduction) there as well.
If that should give you trouble when writing your own code initially, don’t worry! You CAN use the conventional Arduino way for most pins as well.
The LEDs are connected to these pins:
* all RED anodes go to: ‘PD6’ – equivalent Arduino pin: digital pin #6
* all GREEN anodes go to: ‘PD5’ – equivalent Arduino pin: digital pin #5
* all BLUE anodes go to: ‘PD7’ – equivalent Arduino pin: digital pin #7
* common cathode LED0: ‘PB0’ – equivalent Arduino pin: digital pin #8
* common cathode LED1: ‘PB1’ – equivalent Arduino pin: digital pin #9
* common cathode LED2: ‘PB2’ – equivalent Arduino pin: digital pin #10
* common cathode LED3: ‘PB3’ – equivalent Arduino pin: digital pin #11
* common cathode LED4: ‘PB4’ – equivalent Arduino pin: digital pin #12
* common cathode LED5: ‘PB5’ – equivalent Arduino pin: digital pin #13
* common cathode LED6: ‘PB6’ – equivalent Arduino pin: -none-
* common cathode LED7: ‘PB7’ – equivalent Arduino pin: -none-
For ‘PB6’ and ‘PB7’ you’ll have to use direct port manipulation. It’s not really hard, once you’ve wrapped your head around it!
The headers on the backside expose:
* SCL (‘PC5’) – equivalent Arduino pin: analog pin #5 / digital pin #19
* SCA (‘PC4’) – equivalent Arduino pin: analog pin #4 / digital pin #18
* ‘PC3’ – equivalent Arduino pin: analog pin #3 / digital pin #17
* ‘PC2’ – equivalent Arduino pin: analog pin #2 / digital pin #16
You’ll find a simple example to light a single LED the ‘Arduino way’ in the code repo. If you want to light up LEDs of different colour ‘at the same time’, you’ll have to use the supplied code running the interrupt routine. It relies of ‘persistence of vision’ and switches the LEDs on/off very quickly to give the desired effect.
To get proper color reproduction and brightness from the LEDs, you should at least supply 3.5V to it (bypassing the on-board regulator using the “VSEL” jumper). It will work at lower voltages, but colors tend to get somewhat reddish and dimmer. The hard bottom limit is the 2.7V brown-out-reset.
If for example you’d like to use 2 of these as improved tail lights for your bike, I suggest using 3x AAA cells. This would give about 4V in case of fully charged rechargeable ones, or about 4.5V for standard alkaline cells. Remember to stay below 5.0V, if the on-board regulator is bypassed. When the brown-out-reset finally kicks in at 2.7V, both types will be completely sucked dry and you won’t have wasted any energy in voltage regulators.
A ‘high-tech’ power supply could be constructed using 2x AA cells, battery clips, inductor, diode, a few capacitors and a 5V boost converter IC like a MAX756. Using a ‘Minty Boost‘ as inspiration is a good idea.
If you’d like to use 9V cells, which I don’t recommend (expensive, low capacity), set the “VSEL” jumper to its default position (1-2) and feed power to “Vin” and “-“. Please continue reading for more details on using “VSEL” correctly.
As I²C devices only pull the SDA/SCL lines low, you need pull-up resistors to the supply voltage! It may be the case that the libraries supplied with the Arduino IDE enable internal pull-up resistors, but they are only weak pull-ups. It may be necessary to add dedicated 4.7kΩ resistors to make it work reliably.
The on-board low-drop voltage regulator can be used or bypassed by setting the position of the “VSEL” jumper. In its default position (1-2, indicated by the little triangle) the “Vin” contacts are routed through the regulator and you can use voltages from 6-12V DC to power the device via the “Vin” and “-” contacts. In the (2-3) position the regulator is bypassed and “Vin” is directly connected to “+”. Therefore you may only use DC voltages up to 5V, just like on all the other pins of the device.
When would you want to bypass the voltage regulator? If you want / need to power a chain of boards with 5V or less:
To insure that the boards get the correct voltage, I recommend to inject power every 8 units. This is limited by the voltage drop in the copper traces and the brown-out-reset kicking in.
If all you care for is getting the most BANG out of the little bugger and don’t mind color balance much, you can use 91Ω resistors for all colors. The green LEDs gain the most out of this hack, so everything gets a little greener. Yellow becomes a greenish yellow, but white is still white though. The blue LED get a little brighter, but not much. I’d post pictures or a video showing the effect, but my camera is saturated already. The current going through the LEDs (and the micro) is still safe and nothing should fry.
This one doesn’t affect white balance, everything just gets brighter ;-)
It needs some changes in the code as well. Essentially each color is now driven by 2 GPIO pins in parallel resulting in more current going through the LEDs. You’ll need 3 fine wires and another set of 3 resistors (390Ω, 91Ω, 110Ω). Just decreasing the resistors that are already in there would over-stress the output drivers. The bottom left (GREEN – 390Ω) goes to the AVR pin #32 (PD2), the middle (RED – 91Ω) to #1 (PD3) and the right (BLUE – 110Ω) to #2 (PD4).
The code necessary to drive this can be found in the GIT repository. It should be considered as ‘experimental’. If you should choose to apply this hack to your board, make sure to only switch the anodes (e.g. RED_A, RED_A2) at the same time. If e.g. RED_A2 is not used, it must first be declared as an input ( DDRD &= ~(1 << RED_A2) ) and 2nd the internal pull-up resistor should be off ( PORTD &= ~(1 << RED_A2) ). Otherwise it will quasi short RED_A to GND. It doesn't instantly kill the board as there are resistors in there, but nevertheless it's not good practice.
This hack pushes the AVR chip to its limits – and maybe even above. For example one possible and unfavourable LED state is just having _one_ LED statically on. As long as you keep two or more LEDS lit it should be OK. Using the full RGB PWM mode or the 7 color mode is somewhat safer, as the LEDs are multiplexed. Nevertheless if the chip dies I blatantly refuse to be responsible. You’ve been warned.
Connect your favourite USB/TTL adapter to the board and upload using the bootloader. Make sure the pinout matches the silkscreen on the board.
This is easy. Locate ‘boards.txt’ in the arduino folder on your system and add the contents of ‘board.txt.modif’ to it. You can find that file on the code repository page. This provides two entries to the Arduino IDE boards list. One is set for uploading using the ‘optiboot’ bootloader, one for uploading using the ‘usbtiny’ AVR programmer. The correct fuse settings are in that file as well, in case you want to do all of this by hand. As of now, all boards will be preloaded with a demo routine + the ‘optiboot’ bootloader. A combined .hex file is in the code repository as well.
1) Load the sketch “ArduinoISP” (File->Examples…) onto your Arduino board as you would upload any other program to that board, i.e. select the correct board type to match your Arduino board and press upload.
2) Connect the wires as shown below:
3) Change the board type to “RGB LED RING – ATmega168 / 8MHz RC OSC / ISP” and load the sketch you want to upload to the LED ring board. For this to work you must have finished the part about using the custom “boards.txt” with the Arduino IDE.
4) Change the programmer to “Arduino as ISP” (Tools->Programmer…)
5) Compile the sketch for the LED board as usual and then upload the code with “File->Upload Using Programmer”.
Please note that this method wipes the bootloader off the chip. If you should need it again, change the board type to “RGB LED RING – … optiboot 19k2 (default)” and use your ArduinoISP to burn the bootloader.
This should work if you got an assembled board from me. Select “RGB LED RING – ATmega168 / 8MHz RC OSC / optiboot 19k2 (default)” for the board, connect the adapter and compile / upload as usual.
In case this doesn’t work and you have another Arduino board at hand, step 6.2 should get you there. Next to using a dedicated AVR programmer, this method is the most reliable one. Unfortunately the internal RC oscillators of the AVR chips are not that precise, which may hinder reliable serial communication.
Please post a comment with a link to your creations!