Introduction: Easiest RGB LED Strip With Raspberry Pi!
If you've looked into driving RGB LED strips from your raspberry pi, you may have found it to be more effort than you were willing to put in to it. Either you had to build a driver from scratch with transistors, or you needed to modify the circuitry of a mini amplifier to make sure it didn't blow up your Pi.
Well, now you don't have to - there's a plug and play solution, thanks to a fortuitous discovery about a particular model of RGB LED amplifier.
This is the kind you DON'T want: very cheap, highly tempting mini amplifiers, such as https://www.amazon.com/FAVOLCANO-Amplifier-Control...
They have a fatal flaw - the +12V input pin is connected to the +12V output pin. Connect it to your Pi and you'll blow up the Pi.
This is the kind you DO want: slightly more expensive and larger: https://www.amazon.com/TSSS-Repeater-Signal-Amplif... (Cost - $5.75!)
These ones do NOT connect the input and output 12V pins and are safe to drive directly from the +5V pin on the Pi and the GPIO output pins. (Though just to be sure in case there's ever a new design using the same packaging, check that for yourself with an Ohm meter)
Step 1: Connecting Is Trivial!
Connect the +5V pin of your Pi to the +12V input of the amp with a male-female jumper lead.
Connect 3 GPIO pins (GPIO 4,5,6 are a good choice) to the R, G & B inputs of the amp with three male-female jumper leads.
The amp will come with two short connectors for the LED strips. Use one to connect to your LED strip. They'll have color-coded wires - red, green and blue plus one other for the power line. (Black, in my case)
Step 2: Now Test It...
You will need the "pigpiod" system on your pi in order to take advantage of software PWM so that you can drive the LED strips at different intensities. "sudo apt-get install pigpiod" if it isn't already installed.
Go to https://www.raspberrypi.org/forums/viewtopic.php?f... to see how to configure your Pi so that pigpiod starts when you power up.
Here's a shell script that will let you set the LED strip to an arbitrary color:
#!/bin/bash if [[ "$1" == "on" ]] ; then pigs pwm 23 0 pwm 24 0 pwm 25 0 else if [[ "$1" == "off" ]] ; then pigs pwm 23 255 pwm 24 255 pwm 25 255 else # trying to compensate for eye's log response to brightness # tmpR=`echo 'scale=4; (e(l(2) * (((100 - '$1') * 8) / 100))-0.01)' | bc -l` # tmpG=`echo 'scale=4; (e(l(2) * (((100 - '$2') * 8) / 100))-0.01)' | bc -l` # tmpB=`echo 'scale=4; (e(l(2) * (((100 - '$3') * 8) / 100))-0.01)' | bc -l` # but simple linear seems to work better :-( tmpR=`echo 'scale=4; ((100-'$1')*255/100)' | bc -l` tmpG=`echo 'scale=4; ((100-'$2')*255/100)' | bc -l` tmpB=`echo 'scale=4; ((100-'$3')*255/100)' | bc -l` # convert to integer tmpR=`echo 'scale=0; ('$tmpR'/1)' | bc -l` tmpG=`echo 'scale=0; ('$tmpG'/1)' | bc -l` tmpB=`echo 'scale=0; ('$tmpB'/1)' | bc -l` # echo "RGB: "$tmpR $tmpG $tmpB pigs pwm 23 $tmpR pwm 24 $tmpG pwm 25 $tmpB fi fi
Call it "ledstrip" and use it like this: ledstrip 50 50 0
The 3 parameters are the values of R, G & B in a range of 0 to 100.
That's it. Easiest LED strip project ever!

Participated in the
Microcontroller Contest 2017
18 Comments
Question 1 year ago on Step 2
This is a super tutorial! I've got it setup and working!!
There is only one thing that doesn't work.... it will not set the value of the GPIO to LOW, so it will not dim the LED anymore.
This will set the Led to Red: (which works fine)
pigs w 4 1
But this will not set it to LOW, so it remains red
pigs w 4 0
What am I doing wrong ?
Answer 1 year ago
I really don't know, but areas I would look at: have you changed the pullup/down defaults at any time (pigs pud command)? Or changed the pin from an output to an input? Is there any possibility of a wiring short? Can you eliminate the amplifier from the circuit and just look at the GPIO pins with a meter? - do you see the same things? Does the problem also show when you use pigs pwm instead of pigs w?
Question 3 years ago on Introduction
Any idea what I might be doing wrong? I can't get my Pi to turn on the Led's or control them. Using my multi-meter I can see that my Pi's 5v is plugged into the Input V and when I send the command pigs p 23 255 my GPIO23 I read 3.3 V's coming off of it, but on the Output of the RGB amplifier I read no voltage change at all.
If I hook up 2 led strips into the Amplifier it works as expected. Any idea what I'm doing wrong?
4 years ago
Would it be possible to drive a RGBW from a raspberry pi with this:
https://www.amazon.com/LEDENET®-Amplifier-Repeater...
What GPIO pin would you use for the white? :)
Reply 4 years ago
yes, that looks very possible. the extra W and even WW lines became available after I did this project but you should be able to extend it in the obvious way. Any standard GPIO that isn't in use internally by the Pi should be OK, there's a dozen free ones that are easy to use. Just pick one, I have no special favourite. Obviously you'll also need to tweak a script to drive it. Oh wait - did I update this project to only use the built-in PWM? If I was using hardware PWM then I guess you would need a spare hardware PWM pin if there is one, but if it's software PWM then any regular GPIO would do.
Reply 4 years ago
Working fine with software PWM, thanks (:
Reply 3 years ago
Hi.
NickP243, could you tell me the complete name and model of the LEDENET®-Amplifier-Repeater you are refering to?
Thanks and best regards.
Reply 3 years ago
This is the one I ordered:
LTRGBW 24A DC12-24V LED RGBW LED Amplifier 4 Channel Dimmer Power Amplifier for RGBW LED Strip Lights
by LTRGBW
https://www.amazon.co.uk/gp/product/B01LY8QZS6/ref=ppx_yo_dt_b_asin_title_o09_s00?ie=UTF8&psc=1
Tip 4 years ago
Came back here and remembered that I intended to post my Perl code that controls my LEDs. It uses the X11 color database to set the color, or uses a random color (although some of the colors don't look like you'd expect because the LEDs don't render them as faithfully as a monitor would). You will need to install pigpiod as stated in the article and make sure it's running before using this script.
Usage: ./ledrgb.pl [--color=color-name] [--random]
--- start file ledrgb.pl --- cut here ---
--- end file ledrgb.pl --- cut here ---
Reply 4 years ago
Appreciate the code posting, shame it got mangled by Instructables, though would have been much worse if it had been python and lost the indentation!
Reply 4 years ago
Heh, yep. Guess we can't post code blocks in the comments. <code>Or can we?</code>
Reply 4 years ago
Nope, guess the code block formatting is reserved for articles only.
Anyway, since it's Perl, indentation isn't a deal-breaker. Ping me via the site or george <dot> rapp <at-sign> Google's mail product <dot> com if you have any questions or problems with the code.
Question 5 years ago on Step 2
Awesome tutorial! I have a question in regards to setting up something similar. I’m planning to use this setup to control a strip, but I need the colur to change on a gpio pin change (i.e, the LEDs Aden blue, but turn red once a certain pin is high). Any ideas how to implement this in Python?
Answer 5 years ago
I'm not a python programmer, but I imagine any basic GPIO tutorial such as https://learn.sparkfun.com/tutorials/raspberry-gpio/python-rpigpio-example could be modified to suit.
Tip 5 years ago on Step 2
Thanks OP for a straightforward and easy Instructable. My build notes:
* There is a new product on Amazon, and unfortunately the price has risen to US $13: https://www.amazon.com/gp/product/B00MN7UQVQ
* My 12V power supply is on the floor, and the rPi and LED amplifier are up near the ceiling. I only wanted to run the 12V power up the wall, but I needed USB power for the rPi. I wired the output Power + / - leads to a cigarette lighter USB car adapter, and then used a Micro USB cable from that adapter to connect to the rPi.
* My 5A power supply is sufficient to drive 10 meters of RGB LED strips with 30 LEDs/meter.
Reply 5 years ago
Thanks - the best thing about Instructables is when someone builds something you've suggested!
It's coincidental that you just now posted this - this week I ran LED strips all round my living room for use as power-failure lighting and pulled this exact hardware from my box of parts to drive it. I'll be setting up a 12V lead-acid battery on trickle charge (same as most burglar alarm systems) and am contemplating the same wiring issues as you have. In my case I've decided to use a 12v->5v USB adapter for the Pi, and house the amplifier and Pi (ZeroW, if it works) on a shelf close to the strip to keep the wiring short & tidy.
PS If you search around on Amazon or eBay you can find better prices for the same amplifier - currently $5.99 w/ Prime shipping is the best I can see on Amazon. Also there are now RGBW amps with an extra channel.
Reply 5 years ago
I was looking for 12v->5v adapters on Amazon, but decided to try the cigarette lighter adapter first because I have dozens of them lying around. :) 3+ days continuous uptime on the rPi and no issues thus far.
Thanks for the tip on the cheaper amplifiers.
6 years ago
I hear that Broadcom pin numbers 12/13/18/19 are capable of hardware PWM support so may be a better choice than the ones above. OTOH I had previously understood that only pin 18 was supported by hardware PWM so I don't know if this applies to all models.