Wiring to drive an RGB LED Strip

Hi there,

I’ve ordered my Spark and while waiting for it to arrive I’ve been growing various different resources to try and find the best way to wire up an RGB LED Strip to the Spark Core. Since it’s such a new device, I haven’t come across anyone who has shared their success.

I’ve come up with the diagram below, which is based on the Arduino design by Jerome Bernard (although I did pick up a resistor wiring mistake on his green and blue MOSFETs).

I wanted to share this with the community here and get some input on the design. Will it work? Should I make any amendments to the design? The MOSFET’s I’m planning to use are the N-Channel MOSFET 60V 30A from SparkFun and the RGB LED Strip is a simple one I have ordered from eBay which has simple +12v R G B pins.

1 Like

Looks like it should work, I don’t see a problem anyway :slight_smile:

The only suggestion I’d make is hook the gates up to PWM capable outputs (A0, A1, A4, A5, A6, A7, D0, D1)

Depending on how much current you are planning on running to this strip, you may want to run your high power connections off the breadboard, and just tie the ground of all FETs to the breadboard so that a Vgs signal can be created properly referenced to the source pin of the FETs. Also the Spark is only capable of 20mA output to drive the gates, but since these are low gate capacitance FETs you will probably be fine.

1 Like

Look for RGB LED strips that use the LPD8806 chip. You feed it high current (depending on how long your strip is). You control it with 2 simple I/O lines. Mine is 52 LEDs per meter and sold for $30/meter. Documentation is flaky so I had to just play with it. Now working so well that I’m considering getting 40 ft to encircle the whole room. Initially ran it with a PIC. Worked fine but not enough memory for buffer. Now using Propeller with 32K mem.

Rgb123 ws2812 leds for you? :slight_smile:

Thanks BDub – indeed the FET’s I purchased seem to have a good rep among the low power miro-arduino community. The blue LED wiring should definitely be to #4, thanks for noticing my mistake.

I’m planning on powering about 1-2 meters of strip per device, so am thinking that doing it on the single breadboard should be OK, but thanks for your tip. I’ll certainly keep it in mind when I look at doing some stuff around the house.

Hey Don – because these are going into a single-colour light box project, the basic strip will suffice, and much cheaper to wire up. Here’s a link to what I’m trying to achieve.

I’m not sure if I’ll use the Spark as the final core, as I’m thinking a simple Ardiono based DMX controller could do fine, but the Spark gives me an easy way of prototyping the solution to make sure it will work before we start building them all.

I’ve made the changes to A4, A5 and A6 as you suggested BDub. I’ve also changed the resistors to 1% 5 band, which are the ones I’ll actually be using.

Does anyone else have any other changes you think I should make here? I’m still sitting on the edge of my seat waiting for my Spark to ship :slight_smile:

1 Like

Hey Jeff,

Thanks for sharing this. I tried to replicate the diagram shown here, but with Spark Core rather than arduino…

The result was this, https://upverter.com/happymeerkat/3b8cb71b986b611b/Spark-Led/

This is a crude script I wrote that should flash the onboard LED at D7, and in turn turn on each colour in the RGB strip. D7 flashes correctly, but the strip does nothing. No idea if it is my wiring or script that is the problem… when you get your Spark I’ll be interested to see how you get on… hopefully better than me.

Anyway, if the script helps you in any way, here it is: http://pastebin.com/8Dmj1Efp


1 Like

You have the BASE and COLLECTOR of each Darlington NPN transistor flipped. Should be like this:

This code:

  digitalWrite(BLUE, 256);  // #1 you have two blues here as well
  digitalWrite(BLUE, 256);  // #2
  digitalWrite(GREEN, 256);

Should be:

  analogWrite(RED, 255);
  analogWrite(BLUE, 255);
  analogWrite(GREEN, 255);

And you should select PWM outputs for the RED GREEN BLUE outputs… (D0, D1, A0, A1, A4, A5, A6, A7)


Thanks so much, BDUB. I’ve created the BASE and COLLECTOR pins and also made sure I’m using PWM outputs now for my colour outputs. With those changes, I get a very small faint RED led on every section of the RGB, but nothing else… from the RGB strip so I guess I have something else wrong.

I’m a bit concerned I’m hijacking Jeff’s thread so I’ll look and see how Jeff gets on and create a new thread later if I need to.

Thanks again,

1 Like

Hey @Happy, give this code a go: http://pastebin.com/Sws3nz9J

Just modify the pins in the #define and it should fade through the different colours in the spectrum.

If it doesn’t work, maybe your transistors require more power than the :spark: can provide?

I’m yet to get my :spark:, but I believe it should be shipping soon in the current production run.

1 Like

Thanks @Jeff. Still no luck. I’m totally new to electronics so I guess I’ve missed something. I’m guessing the problem is one of the two things…

  1. The power I’m using is no high enough voltage to power the RGB strip (I’m using the VIN pin on the Spark rather than an independent 12V power supply. I’ve cut a very small section (about 4 inches) of RGB strip so assumed the draw would not be high enough to cause an issue… I’m assuming, perhaps incorrectly, if I were down on power I should at least some attempt at activity.

  2. My RGB strip is faulty. The only thing I get on it now I changed the base and collector pins around is a very small red led, that never changes… here’s a picture…

Cheers Jeff,

Ah, @Happy, I would guess your LED strip requires 12V. My understanding is that the VIN pin is 5V whilst VCC is only 3.3V. Either way, this would not be enough for a 12V strip and would explain why it’s not working. I’m actually surprised that it hasn’t drained the Spark’s supply!

The reason you might be getting a tiny bit of red is that the red, green, and blue components of the RGB LED usually have slightly different power draws each.

What kind of transistors are you using? If they’re MOSFET’s similar to the ones I linked in my first post then try using the second circuit I posted and see how you go. If you’re using just a different transistor you may need to put another resistor between the PWM output on the Spark and the base (somewhere between 100-220 ohm depending on the transistor I believe).

If you want to check whether your strip is OK or faulty, simply hook up a 12V power supply to each of the contacts on the strip. As you connect the [-] line to [R] or [G] or [B] you should see it light up in that colour.

Thanks so much @Jeff.

I’m using TIP120 Darlington transistors but I guess its the power supply. I’ll test with a 12V today, thanks again. What do you prefer to use as your external 12v power supply?


12V 1A power adaptor is pretty common here. Not sure about your side.

Thank you kenneth :slight_smile:

Indeed, I’m just using a 12V regulated power pack similar to this one: http://m.jaycar.com.au/m_productView.asp?ID=MP3312

Just running it in 12V mode with a DC barrel connector on my breadboard: https://www.sparkfun.com/products/10811

Hope this helps :smiley: and let me know how you go :slight_smile:

I am about to do mine, I’ll post the results later!

Hey folks, I’m working on a project for under cabinet lighting and I am planning to use this to up convert the power so that I can run up to 210W or 6A per channel, thoughts?

@srfnmnk, that module needs another module (LS-PWM-6A) to work. You will also need a 12v or 24v power supply that can provide the max 210W. What exactly are you trying to achieve with the lighting? Will you be using 12V lighting strips and dimming them?