Practical PIC Projects



RGB LED Strip Controller
high-side LED drive

for PIC12F629


  • Overview

  • Schematic

  • Circuit Description

  • PCB Artwork

  • Notes on LED strips

  • Constuction

  • Firmware




Recently I acquired a 5M length of RGB LED strip using SMD5050 RGB LEDs.  It has built in current limit resistors designed for operation from a 12 volt supply.  Having thought this would directly attach to the Picprojects MOSFET RGB LED driver project  I went ahead and bought one only to discover when it arrived that it wasn't going to be that easy.

Despite the description and markings on the supplied strip indicating it had a common anode connection it is in fact common cathode.  The terminal marked '+' in the photo below is a common ground connection - go figure?

What is required is a high-side driver so the three LED anodes can be controlled by the PWM output from the PIC microcontroller while the common wire connects to ground. 

With the requirement defined I decided to put together a quick project to work with the LED strip.  The controller on this page is an adaption of the RGB Mood Light 101 project, firmware is the same and can be downloaded from that project page.


You should be aware that not all LED strips use a common ground, I have 1 metre strip that is wired with a common '+' or high-side and works pefectly using the Power MOSFET RGB LED driver kit 106  See my notes on LED strips here

Please note:

This project is NOT available as a kit, or PCB nor can I supply the LED strip.


Assembled board from schematic #1



schematic #1


Circuit Description

The circuit is essentialy the same as the RGB101 Mood Light project and uses exactly the same fimware.  Where it differs is in the LED output drive stage.  Instead of the BC548 transistor (Q1-Q3) driving the LEDs directly they are used to switch a second set of transistors (Q4-Q6).  These are STX790A medium power PNP transistors switching the 12 volt or high-side of the power supply.  

The current rating of each colour in the strip is around 1.5 amps which needs a medium power transistor to control it.  I've avoided using a P-channel MOSFET as they are both expensive and less easy to obtain.

The transistor used for the final output is an STX790A  rated at a maximum collector current of 3 amps, with a minimum current gain of 100. The LED strips I used require about 1 to 1.5 amps per colour.    Base current for Q4-Q6 is derived from the collector current of the BC548 transistors (Q1-Q3) via R1 - R3.  Resistors R1-R3 provide around 20mA of base current to the STX790A.  I've used 560R 0.25 watt carbon film resistors here, they are operating right on their power dissipation limit for a 0.25 watt resistor.  Since the transistors are driven with a PWM signal average power dissipation is lower so not an issue.

If you decide to use an alternative transistor type for Q4-Q6 and need to increase the base current you'll need to use a 1/2 watt resistor or go for a metal film 0.4 watt or 0.6 watt which are the same physical size as a 0.25 watt carbon film.

For Q1-Q3 any small signal NPN transistor will work.  BC546, BC547 or BC549 are also suitable and have the same pinout as the BC548.

If you need more than 2 amps per LED channel you will need to do some redesign of the final transistor output section since the circuit is not designed to handle more than 2 amps on each channel.

The rest of the circuit is straight forward.

The 12 volt input to the board is fed through D1 to a 78L05 5-volt regulator (IC2).  D1 provides reverse polarity protection to the regulator though it should be noted this does not protect the LEDs and final driver transistors since due to the high current requirements of the LED strip it is not practical to use a diode here.

Capacitor C1 provides decoupling of the 5 volt supply.  Capacitor C2 provides filtering on the input side of the regulator.  C1 should be as close to the PICs Vdd/Vss power input (pins 1/8) as practical.  The 78L05 and C2 should also be reasonably close to each other and the PIC.  R7 provides a pull-up for the PICs MCLR reset input.

S1 is the mode control switch.  JP3 just provides a pair of 0.1" spaced pads for connecting a remote switch if the board is built into a housing.

JP2 is the LED output connector.  Take note of the connections on this.  The ground, red, green and blue connections have been placed to match the LED strip I was using.  You should verify the connections to the specific LED strip you use to ensure they are the same. (see notes on LED strips here)

Also remember the board switches the high or 12 volt side with the ground connection being common to all three LED colours.   If you have a common anode strip you will need the Power MOSFET project.

R8/C3/JP1 are not used, do not fit components.

Power to the board is fed via the two connections marked Gnd and +12V.  Be sure to use a 12 volt DC regulated power supply rated at 2-3 amps.  Also note the hole on the PCB between the power connection pads.  Pass the two power connecting wires through this to provide mechanical strain relief for the wires/solder joint (see construction photos further down the page)

STX790 datasheet

PCB Artwork


PCB after etching and drilling


Notes on LED strips

I've only bought a couple of these flexible LEDs strips so far but having had a bit of a look on the Internet at what's being sold on eBay and elsewhere here are some of my observations which you may want to consider when purchasing an RGB LED strip.

  • LED strips seem to be supplied with either 30 LEDs per metre or 60 LEDs per metre.
  • LED strips are available for use on both 12 volt and 24 volt supplies.

    If you want to use this controller with a 24 volt supply you will need to change the following:
    • R1 / R2 / R3 - use 1K2 1/4 watt carbon film.
    • C2 - use 22uF / 35 volt electrolytic
  • There doesn't seem to be a standard arrangement for the pin-out of the LED strip.

    The one I used here shows [ + B R G ] on the connector end but is actually [- B R G ], however I've also seen [ + G R B ] where the blue and green connections are swapped.
  • Strips can be wired with either the '+' (high side) or '-' (low side) wired as the common terminal

    As I discovered, don't assume it is common + or common - just because it says it is in the description or even if it's printed on the LED strip itself.  Check it out yourself to confirm how it is wired.
  • Be aware of what you are buying.
    • Most of them supplied with a controller don't include a power supply.
    • If it seems cheap it may be the 30 LED/metre rather than the 60 LED/metre
    • Check the length you are buying, most seem to be 5M, I've also seen 10M, 3M and 1M.
  • Some of these LED strips are sealed with a clear flexible plastic over the entire length making them waterproof and less susceptible to mechanical damage.  Others are just the components soldered to the flexible printed circuit strip, non-waterproof and less robust for some applications.

Construction notes:

I haven't done a full detailed construction section here since this project isn't being sold as a kit.  With the information provided in this section and reference to the schematic, PCB artwork and circuit description elsewhere on the page any reasonably competent electronics enthusiast should have no problem building this circuit.

photo 1.

photo 2.

photo 3.
  • General photos of the assembled PCB.
  • Note physical orientation of the components.
    Apart from the switch, C1 and the resistors, all other components need to be fitted the correct way round including D1 and C2.  Check the photos here and the PCB overlay in the section above.
  • The PIC12F629 has not been installed yet.
  • Once you get the board assembled connect to a 12 volt DC power supply and then check the voltage between pins 1 and 8 of the IC1 socket.  Make sure this is between 4.8 and 5.2 volts before continuing.

photo 4.

photo 5.

photo 6.
  • The LED strip was supplied with a double ended SIL (single in-line) pin header.
  • I designed the layout of the PCB to use a similar 4-pin socket matching the connections for the Ground, R, G and B connections of the LED strip.
  • As has already been noted in the Overview section of this page, despite the LED strip have a '+' marking on the common connection it is in fact a common ground
  • Use some reasonably heavy gauge wire for the power connections to the board.  They will need to handle around 3 amps.   Also make sure the power supply used is a 12 volt DC regulated output rated for 3-4 amps (or >36 watts)
  • The PIC12F629 will need programming with the firmware rgb101g3_main.HEX




The firmware is the same as that used with the RGB Mood Light project 101

Please refer to the project page here for Firmware download and operating instructions

Contact us: