Introduction: Open Source Microchip LED / PWM Driver Project

This instructable fully describes building a PWM driver to control four LEDs from one small Microchip 12F609 board.

The original design was called the "Kemper LED Lamp" and I sold a few lamps to several brave folks through my web site. However, I've come to discover selling small quantities to a few folks is a major pain in the backside. Hand soldering these together and then selling them at $4 bucks each is no way to make money.

So, I'm going Open Source baby. I'm hoping that more people can enjoy these wonderful little lamp drivers. I've put in way too much work for these little gems to sit idle on the shelf and not get used.

With the information I'm providing here, you should be able to program your own Microchip 12F609 micro, connect a couple LEDs, and have your PC command some LED action. 

For reference, here are links to my prior Kemper LED instructables:

Those two links have a bunch of information that cover the lamp design in detail. There are even a couple video demos in those instructables that, I think at least, are cool too.

Note, if anything new comes up you can always check my web site at:


Step 1: Hardware Design

The hardware is painfully simple. The micro drives four outputs and receives / sends commands on the fifth. Couldn't get much simpler.

Eventually, I ended up with a board design that is 20mm x 15mm. To keep the cost down I used CAMtastic to array the lamp boards onto a larger board. I arrayed the lamp boards using a grid of 8 x 8 with a 0.055" gutter between each lamp. The gutter makes it easy to cut the lamps apart with my cheap-o bandsaw.

Step 2: Software Design

Programming the 12F609 separates the men from the boys. While the hardware may be super simple, the software is not. I spent weeks (OK, maybe two) pouring over this stuff. The code below has been highly optimized just for this application. There is practically no RAM or ROM leftover to spare. In fact, I ran out of RAM many many times and had to ether drop functionality or look for more optimizations.

The 12F609 does not have a UART. So, receiving new commands while maintaining the PWM channels became my nightmare. The PWM channels must be maintained even while a new character is being received. The human eye is just so good at seeing the smallest blip emanating from an LED.

Receiving a new character using software is no big deal. But, receiving characters while updating PWM outputs is. The trick is to update the LED output channels while waiting for the next bit on the comm link. In effect, it's multitasking, and getting it all working was a major hassle. Simply impossible without a LSA (logic state analyzer). I used one output pin as a debug pin. I'd toggle the pin on certain events and watch for it on my LSA. Using this trick, I could watch each bit being received by my code.

OK, OK, enough already. Below you can find the source files that do all the magic. I'm publishing them in the hopes that others can learn from my efforts. There really is some good code in there.

Instead of describing all the software in detail, the comments in the code should explain most stuff. Remember, when in doubt "Use the force - view the source." I added a bunch more comments to the code in an attempt to make it more readable. I hope you'll agree that it is, indeed, readable.


Update: May 16th, 2012

Below is a Zip attachment which has 32 hex files within.  Each hex file is the same except for the hard-coded node number.  So, to flash node #1 use file "1.hex" to program the micro. 

This should help folks who do not have access to the CCS C Compiler.

Step 3: Datasheet

Attached to this step is the datasheet that goes along with the project. The datasheet does a good job of documenting each protocol command.

Well, that's it. Hope you find some good uses for the Kemper LED Lamp.


Tester09 (author)2012-05-16

Is possible to publish or receive the file .hex?
Which program has been utilized for compilation?
What should be connected to connectors P1 and P2, under Comm?
By chance the PWM Driver Project, must be connected to an Arduino?
Is possible to use it independently, without connecting all'Arduino (which I have)?
Thank you.

jimk3038 (author)Tester092012-05-16

Yes, have a look at step #2 - I just updated the step with the new hex files. I've added a zip attachment which has 32 hex files within. Each hex file is the same except for the hard-coded node number. So, to flash node #1 use file "1.hex" to program the micro. In other words, the hex filename indicates what node number is hard-coded inside the file.

I used a C compiler from CCS to compile the code. I used PCM C Compiler version 4.087.

For connecting P1 and P2, have a look at the schematic in Step #1. The connectors are designed so that power and communications passes through. If you look at the circuit traces on the bottom of the circuit board it becomes very clear that the signals just pass through. Pin #1 is +5Vdc, Pin #2 is ground, and Pin #3 is TTL communications (9600 baud / 8 bits / no parity). You can use either P1, P2, or both.

Yes, the nodes must be connected to an Arduino. Each node is a slave and won't do anything without being commanded to do something. Without any master commands nothing happens.

Yes, you could replace the Arduino with a regular laptop or PC. Just make sure to use a 5 volt TTL serial port. These can be found at Sparkfun for under $10 bucks.

Good luck,

Tester09 (author)jimk30382012-05-17

Thanks for giving me the answer and good explanation.
So your circuit, you can use it both with the Arduino and the computer, in the absence of the Arduino, right?
Is possible to use the file .hex for 12F629 and 12F675 pic (because right now I have no pic 12F609)?
As a USB-TTL, I have an inexpensive adapter CP2102 (already tried with other PIC and AVR).
What is the program to handle the RGB controller from Windows?
Hello and thank you.

jimk3038 (author)Tester092012-05-17

Have a look at my web site where I have a bunch more information:

At my web site, I have a Visual Basic application that can be used to send commands to the nodes. It's good for testing new nodes. The source code is available too. However, I find Python a better tool for testing. Let me know if you want some Python code examples.

I would guess that the hex code would work with the other chips. If does not work you can just erase the chip - no harm done. It's worth a try as a test.


Tester09 (author)jimk30382012-05-17

Thanks for the replies.
When I can, I try if it works first on the 12F629 and 12F675, 12F609 then when I have, I try this, too.
Python, would only work under Ubuntu Linux?
Why at this time, the laptop I have Windows Vista, so not sure there is a version of the Python for Windows.
I'll know when I can.

jimk3038 (author)Tester092012-05-17

The best part of Python is that it runs on almost anything. For sure, you can run Python on Windows Vista. I've run Python on both WinXP and Win7 without any problems. But yes, I think Python works best on Linux. Everything works better on Ubuntu / Linux!

Good Luck,

sokomm (author)2011-04-17

I got all the part for this project and some 4pin RGB Leds and now wonted to try it out and I realized that diodes in the schematic use a common anode, and 4pin RGB Leds use a common cathode :( .
If you ever decide to rework the design with the new micro it would be great if the polarity for powering led is inverted. Any way great job keep it up !!!

ForgerOfPie (author)sokomm2011-08-22

I bet you could find some common anode RBG LEDs somewhere. After all, we have the internet!

jimk3038 (author)sokomm2011-04-18

Have a look at step one where the PCB layout is shown.

On the top side of the board, the feed trace for the LEDs could be cut and re-routed to ground instead. This would enable you to use your common cathode LEDs instead. No change to the micro or software required.

Also, have a look over at Hack-A-Day, I saw a post recently where someone was creating something almost identical. Maybe there is an active project going over there.

Hope this helps,

waweru john (author)2011-01-18

wow!! have very interesting and educating lessons thank you and keep it up.

jimk3038 (author)waweru john2011-01-18

waweru john,

Thanks for the comments.  This design is getting a bit dated since I originally started. Microchip now has a 80 cent micro that has a UART!  That would have made life sooo much easier.  I actually was tempted to rework everything with the new micro. 

However, GE Lighting has introduced a new line of Christmas lights that are programmable.  Each GE bulb has an RGB LED. The string of bulbs can be hacked / controlled with an Arduino.

Still, if you only want one or two bulbs the Microchip processor might still be the way to go. 

Anyway, I'm still posting lots of stuff on my web site. You can find the latest at

Thanks again,

dave77459 (author)2010-10-28

I've always imagined that I could use an Arduino to control glowy LEDs on my motorcycle, but haven't the stuff to imagine how. I'd like a solid on, as well as a "breathe" mode where the lights brighten and dim. Seems simple enough, but how?

Do you reckon this could accomplish that? Can it drive a couple hundred LEDs, and be vibration resistant?

jimk3038 (author)dave774592010-10-28

Yep, you sure could use an Arduino to control a couple of LEDs.

There are a couple of tricks to making that happen.

The biggest trick is driving all those LEDs. Each pin on the Arduino can drive only a single 20mA LED. With a big monster transistor that problem goes away.

The other trick is generating a smooth pulse width modulated (PWM) signal out of the Arduino. Looks like "maybe" the new Arduino Uno has the ability to generate PWM signals right out hardware. That would be sweet - simply setup some timers and the PWM signal starts. In that way, doing other things with the Arduino won't goof the PWM output. The human eye is really good at seeing the smallest little glitch in a PWM signal.

Anyway, to answer your question, yes, a new Arduino Uno with a big butt transistor and your in business.

Good luck,

kimvellore (author)jimk30382010-10-28

I have been playing with PICS for a while and when I wanted to control many LED's with multiple intensities it was a pain to code it and not to mention bulky add on drivers. In my quest for finding a solution I came across some chips listed below that kind of do the same function with built in drivers etc..
I like the ones with programmable intensity so dont have to bother with coding for independent LED intensity control.

CAT4016VS-T2 from On Semi
TLC5928DBQ From TI
PCA9632TK2,118 from NXP

This is just a sample there is a huge variation of options including the number of LED, current, communication etc etc.
for a similar function listed here one can pick the 4 led version. This is a great project with many other pros.



jimk3038 (author)kimvellore2010-10-28


Thanks for the pointers to other parts.

One thing to note, the "itch" that I was trying to solve was different than these driver chips can solve. Typical driver chips have no brains. They won't, on their own, slowly ramp a LED. To perform ramps, the master must send each new intensity level over the serial comm bus. This becomes a real pain with lots and lots of LEDs.

My design adds the brains in the 12F609 chip. Each 65 cent part has 2 MIPS of brain power. So, you can send the lamp one command that might take up to 4 seconds to complete. While the ramp is happening, the lamp will accept commands to perform a different kind of ramp for another LED channel on the same lamp.

Bottom line, these lamps have intelligence to complete tasks. There not just SPI LED driver chips. This is a big difference.

But again, you application my be different. These lamp are targeting applications where the master node can't send tons of SPI messages.

This design tries to off-load the burden of keeping the PWM signal updating smoothly from one intensity to another. The one wire comm bus is also a nice feature when string long runs together.

So it all depends on the application,

dave77459 (author)jimk30382010-10-28

Thanks for the reply. So you are saying I wouldn't need the daughter board?

I apologize for my cluelessness, but I gotta think there is a cheaper and better way to light up my bike than with a $400 solution that has only on/off.

Thanks again!


jimk3038 (author)dave774592010-10-28


I too must apologize - I'm not an Arduino guy. I don't know what a daughter card is.

But, the Arduino is cheap fun. I just looked at Sparkfun and they have Arduino boards for under $30 bucks. I love cheap dev. boards like that. Cheaper than taking the wife, and kids, to dinner. Just don't tell them I said that!

My suggestion is to get a $30 Arduino board and play with it. If you can get one LED to ramp & decay then adding a transistor to get a 100 to do the same should not be a big deal.

Here is a link to inexpensive LEDs that I use:

These are wide angle (120 degrees) 200+ mcd (milli candle) LEDs. A 100 of these throbbing on your bike would look cool. A 100 red LEDs will set you back $17 bucks.

So, $30 bucks for an Arduino and $17 bucks in LEDs. I'll bet the transistor will only be a couple of bucks.

But start slowly, get the Arduino working on the bench with one LED first. Then buy a bag of LEDs from Best Hong Kong. Get a bunch of them working on the bench with a transistor. Then, finally, start thinking about wiring the bike.

Using the PWM signal from the Arduino you can make some really nice fading on / off effects. And not just simple on / off stuff.

Also, there is a guy who writes articles in Nuts & Volts magazine. He writes a lot about the Arduino. Might be a good source to get started with.

Good Luck,

dave77459 (author)jimk30382010-10-28

Thanks Jim! I appreciate your research and tips!


robot797 (author)2010-10-25

are you selling those
else i want to buy a few from you

jimk3038 (author)robot7972010-10-25

Until I find someone to manufacture the boards it's really not practical to hand assemble the boards for resell.

However, as you can see in step 1 (forth picture) I still have a sheet of 64 boards. I can cut these apart and sell the individual blank lamp boards. The board will need the micro, one cap, and four resistors soldered down (and of coarse the LEDs).

So, if your still interested, send me an email to: Jim . Kemp @ Ph-Elec . com

Thanks for your interest,

robot797 (author)jimk30382010-10-26

what is the easyest way to controll the by arduino

a script put *******red=high (dots are the chip number)

jimk3038 (author)robot7972010-10-26
I've updated step #2 with some Arduino demo source code. Click on step #2 and you can download the full Arduino project.

The Arduino code is just a demo of what can be done. To turn on an LED two commands are sent. One command sets the ramp rate and the second sets the intensity. The following code will ramp the red LED on node ten to full brightness using a four second ramp.

node = 10;
setRampRate( node, R, 0x01, 0x01 );   // Set ramp / decay to super slow. 
setLevel( node, R, 255 );             // Set red led intensity to 255.
The datasheet documents all the commands.

Hope this helps,
robot797 (author)jimk30382010-10-26

that is awsome

kyle brinkerhoff (author)2010-10-25

hey wanna sling one of those my way? i would love to use one of those on my robot for the under glow!


I looked at your instructable - very cool. I'm actually planning on a winter project to design a super cheap robot too. I'm hoping to design a robot that can be built for under $20 bucks. What kids need is to have their OWN robot to play with. The Lego Mindstorm is just way too expensive. I'm going to use the STM32 Discovery board ( ) which cost $12 bucks at mouser. I also found some $3.50 servos I can hack for continuous rotation. So, one 32 bit micro running at 25 MIPS plus two servos for under $20 bucks! I call it COPPER for "Cheap O Pint-size Programmable Educational Robot". Well, at least if I've got the acronym sorted out. :) I've all ready started porting FreeRTOS to the board. I've used FreeRTOS on a commercial product before so it should not be too big a deal.

Anyway, I can just blabber on and on. Back to your question.

Yes, this would be perfect for under your laptop / robot platform. Would only take one more Arduino pin to command the LEDs. The Kemper LED Lamp would make for a nice pulsating glow. You could even have three, our four, lamps all strung together on the same comm pin. With four Kemper Lamps you would have 16 LEDs under your control using only one comm pin.

Like I said, I've got 64 blank boards in my shop. I'll make these available for $3 bucks each plus $3 shipping USPS. Note, these are blank boards. You will still need to add micro, cap, resistors, and LEDs. I've added the blank board as a product on my web site:

I'll also look into adding the board to BatchPCB as a product that can be ordered. They will do a better job than me at handling orders.

Thanks again for the interest,


pretty cool idea! but you know what would be really neat is if you could integrate your robot all onto a single pcb, thus eliminating any need for extra materials for the chassis, of course it couldent handle the weight of a netbook, but it would make production even cheeper, although you would probably have to make some special bracket for the servos to stay in place on the pcb.


My idea was to have the STM32 discover board (motherboard) do as much as possible. Still, there are a couple of things that the motherboard can't do. To drive the motors in the servos we're gonna need a H-Bridge. I've had luck with the Toshiba TB6612FNGCT-ND ($2 bucks at Digikey). See the attached pic. The STM32 can drive PWM signals into the H-Bridge unattended once setup. The Toshiba chip has two H-Bridges and can handle 1 amp loads. Should work well.

I've also order TI's Zigbee radio 595-EZ430-RF2500T from Mouser. Kinda blows my $20 target price since the radio costs $22 bucks be itself. Still, having a radio link would be sweet.

As you might be able to tell, I have a problem with "feature creep".


dreadful90 (author)2010-10-24

wow its really interesting

jimk3038 (author)dreadful902010-10-24

It blows me away that each Microchip is zipping along at 2 MIPS. And to be able to have that for 60 cents is really amazing.

Thanks for the comments,

About This Instructable




Bio: Founder of Powerhouse Electronics. For more info goto:
More by jimk3038:Easy ESP8266 WiFi Debugging with PythonRaspberry Pi Internet Weather StationMake Your Own Laser Cut Standoffs for Electronic Projects
Add instructable to: