LED Strip Controller W/ LED Amp + Arduino

180K50472

Intro: LED Strip Controller W/ LED Amp + Arduino

Forget about DIY LED drivers with mosfet transistors! It is extremly simple to drive high powered LED-strips with Arduino at low cost without getting into too much circuitry. The secret is cheap mini LED Amplifiers.

This instructable is just about driving LED strips. If you want to see an application, see this Instructable: Arduino Helipad for mini Quad Copter

*** A word of warning - some people have had problems with overloaded/fried Arduinos using this instructable. Please read the comments before deciding to try it for yourself. If you come up with a more robust twist to the project, please comment below! ***

STEP 1: Background and Circuits

See pictures for three circuit examples. The first picture reflects the implementation in this Instructable. The second circuit is for two RGB strips (uses all 6 PWM out on the Nano). The third circuit is for six single color strips (all Nano PWMs). Each mini LED amp can put out up to 12 amps. You can put more in parallell or at the end of a strip light as many meters of strip you want, provided you have a good 12v power source.

Each LED "pixel" on a strip consists of three light emitting diodes (LED). Most LED Strips are common anode. This means that the positive end of the diodes are connected at +12v at both ends of the strip. Connect +12v to the anode and 0v to B, R, G to light each circuit up. Single color strips and RGB look the same to the naked eye. Even single color strips have copper connectors which are labeled +12v, B, R and G even though all LED's are the same color.

LED Amplifiers/Repeaters are sometimes called RGB amps. Don't let that fool you. They work just as well for single color strips. A LED Amp is fed by 12v and has inputs/outputs labeled +12v, B, R and G just like the strips. The inteded use of the device is to take the input voltage potential, which can be considerably lower than 12v at the end of a long strip, and boost it back to 12v by feeding more power. I have discovered that a 5v voltage difference on the input is enough to get the LED amp to boost the signal to 12v on the output which means that we can toggle the Amp 12v outputs by means of Arduino digital pins. Arduino digital outputs operate at 0 or +5v.

The circuits connect 5v out on the Arduino to 12v on the LED Amp input (common anode). This may seem wierd. I'll try to make some sense of it. The R, B, G inputs of the amp are attached to Arduino digital out. Setting a pin to 0 creates a 5v potential to the common anode which will result on a 12v potential on the corresponding output which will light up the LED. In other words, a digital 0 turns the light on. A digital 1 turns it off. Or, when using PWM duty cycles, 255 is off and 0 is on.

STEP 2: What You Need

Go shopping (probably ebay) for:
  1. 5050 SMD LED Strip
  2. Mini LED amplifier/repeater(s)
  3. Arduino Nano (or other preference)

STEP 3: Wire It Up

Wire the Arduino to the input and theLED strip to the output of the LED Amp seen in the picture. You can power the Arduino from +5v or +12v (not some versions of Arduino. Check the spec). Your choice.

STEP 4: The Software

Download Arduino IDE from http://arduino.cc/en/main/software and flash the following sketch to try it out. The sketch was used on the RGB strip as seen in clip in step 5. It fades each color up/down then white up/down.

int ledPinR = 3;
int ledPinG = 5;
int ledPinB = 6;

void setup()  { 
} 

/* Note:
When driving LED's using common anode LED AMP's you have to inverse the duty cycle,
i. e. 255 is off and 0 is full power.
*/

void loop()  { 
  // Red
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPinR, fadeValue);         
    delay(30);                            
  }
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    analogWrite(ledPinR, fadeValue);         
    delay(30);
  } 
  // Green
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPinG, fadeValue);         
    delay(30);                            
  } 
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    analogWrite(ledPinG, fadeValue);         
    delay(30);
  } 
  // Blue
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPinB, fadeValue);         
    delay(30);                            
  } 
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    analogWrite(ledPinB, fadeValue);         
    delay(30);
  } 
  // White
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    analogWrite(ledPinR, fadeValue);         
    analogWrite(ledPinG, fadeValue);
    analogWrite(ledPinB, fadeValue);
    delay(30);                            
  } 
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
    analogWrite(ledPinR, fadeValue);         
    analogWrite(ledPinG, fadeValue);
    analogWrite(ledPinB, fadeValue);
    delay(30);
  } 
}

STEP 5: The Result


64 Comments

Thanks for a great post! I used your circuit and added a sound sensor to analog 0:

The arduino code:


int soundSensorPin=A0;
int soundReading=0;
int soundThreshold=500;
int intensity[3]={0,0,0};
int LEDPins[3] = {3,5,6};
int numberOfPins=3;
int currentPin=0;
int fadeCounter=0;
int fadeDelay=50;
boolean switcher = true;

void setup(){
pinMode(soundSensorPin, INPUT);
for(int i=0; i<numberOfPins;i++){
pinMode(LEDPins[i],OUTPUT);
Serial.begin(9600);
}
}

void loop(){
soundReading=analogRead(soundSensorPin);
if(soundReading<soundThreshold){
Serial.println(soundReading);
if(switcher){
aboveThreshold(currentPin);
switcher=true;
delay(50);
}
} else {
if(switcher){
belowThreshold();
switcher=true;
}
}
}

void aboveThreshold(int cPin){
switcher=false;
if(intensity[cPin]>200){
intensity[cPin]=0;
delay(20);
currentPin=currentPin+1;
}

if(currentPin==numberOfPins){
currentPin=0;
}
}

void belowThreshold(){
switcher=false;
fadeCounter++;
if(fadeCounter==fadeDelay){
fadeCounter=0;
for(int i=0; i<numberOfPins;i++){
analogWrite(LEDPins[i],intensity[i]);
}
for(int i=0; i<numberOfPins;i++){
intensity[i]++;
if(intensity[i]>254){
intensity[i]=255;
}
}
}
}

I'm powering my arduino nano 5volts, ULN2003 12volts and the led strips 12V too, I'm using a extra arduino without a ic , I power it 12v through barrel jack and use vin pin for powering 12v stuff( my led strips were originally 2 meters, I chopped it in half and using one of my strips )
I have a doubt. Is this code for Common anode or Common cathode Led Strips? I have Common anode

i follow the same setup, but it ended up frying my arduino uno's COM port, can someone tell me what's wrong? below is the battery i'm using

When I see the battery its 13-volt battery!, Arduino COM Port can only handle up to 5v, Barrel Jack can handle up to 12Volts . This is why your arduino's COM Port got fried. The USB controller (ATMEGA 16U2) maybe also be fried with it
I have a question..How can you (if you could) connect a speaker
to work with the rhythm of the song?

Thanks for pointing out these amplifiers - very handy for the strips. BUT the way of using them described here is fundamentally wrong. It seems to work, if with some glitches - at least, my lights did shine on Christmas, but really, I was inexperienced and in a hurry. Now I had time to dig a bit deeper.

Here, the insides of the amplifier. It doesn't measure any voltage potential difference or such, it just tries to sink 12v (11v in fact, after resistors) in the input channels, namely in 5v inputs of Arduino. It successful - the LM124 chip on the right opens the corresponding mosfet, sinking current from output (LED strip). If not - mosfet stays closed, no light. Simple and good: the amplifier actually handles all the ampers in the strip! So:

1) do not connect 5v to 12v input. Even if it doesn't fry your Arduino, there's no sence: all 12v ins and outs of the amplifier are directly connected.

2) Arduino seems to be rather abuse-friendly, but still, it's a very bad idea (and practice) to abuse it. Don't sink 11v in 5v pin. In my case, this worked until I tried to send 0,0,0 (or even 5,5,5) to the strip - Arduino gets overloaded with overvoltage and shuts down.

What to do? Well, I think one can find the right combination of zeners/resistors to sink excess voltage from the amp. I didn't. I used a cheap Darlington array (ULN2003a to be exact) between Arduino pins and amplifier inputs (plus a ground connection). Basically, such an array can be used even without the amplifier, but you'll have to worry about power ratings - each led of the array can sink up tp 500mAs, so for the full strip you'll need 12 legs in 3 groups of 4 connected in parallel. With the amplifier I used 6 legs for two strips. Good!

Another possible good use of the amplifier is with LED drivers like TLC5940, that will happily sink 12v, but you'll have to get the PWM frequency right. I tried with DM631, that has in-built PWM generator, it seems to be too fast for the mosfets.

And, by the way, I tried removing the 100k resistors connecting 12v to inputs from the amplifier - no luck, 5v from Arduino is just not enough to switch mosfets. I guess one can remove everything except mosfets and then patch inputs right to their gates, but it's a bit too drastic for me.

Thanks again for the idea!

The use of ULN2003a it's a really good idea. But one question, what about the 12V input of the Amplifier? It's connected same 12V as the output?

Thanks!

Wow, that was a thorough analysis. Thanks for that! Admittedly the project was derived from trial and error in combination with basic assumptions. Having said that, I have been using it successfully for a year for some of my lighting. Perhaps I have been lucky and got my hands on a couple of pristine Ardu's. I will post a note/warning at the top of the instructable.

I think I have an idea of how you hooked the darlington array up but if you have a circuit drawing, I (and subscribers) would certainly like to see it.

As for the TLC5940s, you are right. That is the best option, especially for ambitious projects. I have first hand experience. I use two daisy chained chips giving me 32 PWM pins of which I am using 21 pins to power 7 LED amps which power 7 2,5m RGB strips (17,5m tot). Works great! I haven't had the time to make it into an instructable yet though.

I'm not that good at drawing circuits, but thankfully with Darlington arrays it's rather easy - lower leg just controls upper leg, + 2 contacts for Vcc and Gnd.

Can you tell, please, did you use the TLC5940 library by Alex Leone? Did you change anything in it - especially the PWM freq generator?

Is there a +12VCC on the ULN2003 or is you circuit drawing correct ?

Thanks

The drawing is correct, no +12v goes to the ULN2003

Tried this out today, worked great. I ended up going with a Photon (by particle,) along with their Shield Shield, which has a voltage regulator, and a 3.3v->5v voltage translator built in, which seemed to work just as well as the ULN2003a to trigger the RGB amp. The Shield Shield and Amp use the same power supply, and fit very neatly into a small project case. I'll post pics soon. I do NOT have anything going to the 12v pin on the input side of the RGB amp.

For code, I started with what I found here to get started, then re-wrote it to suit my goals:

https://www.hackster.io/plaetzchen/a-30-00-led-str...

I actually ended up making my own board that is essentially an Arduino designed specifically to drive 5 RGB strips (or more with an extension board). Did some mistakes (the voltage regulator overheats and forgot to include a master MOSFET, will correct in next version), but it works. Dissecting an amplifier actually helped to crystallize the idea.

wow, nice work! How did you make the board? More importantly, how did you learn to do that? I'm a weekend tinkerer, but I'd definitely like to learn more.

Simply put, I googled and experimented. The main question however is not how, but what for. If you don’t know what you want, Google will give you 42.

I'm a weekend tinkerer too, got an arduino as a present a year ago. Did my first projects on a breadboard. Bought lots of "modules" – they are still gathering dust somewhere. Basically, you quickly grow out of the breadboard because of its limitations – not to mention inconvenience – and you have to learn soldering in any case (at least to use non-DIP chips on a breadboard with a connector). Tried prototyping boards – found out they have the same limitations and are awfully clumsy. Decided to make my own boards, as it's pretty easy to etch them with citric acid. In fact, I actually used etching technique (aquafortis – asphalt paint, needle, drawing lines by hand) as I don't have a laser printer. Even made a specific-purpose arduino with this (below – it really works despite the appearance), but again: limitations (one side only, no replicating). So, switched to Chinese manufacturers who can print you 10 boards at a very reasonable price (in fact, they print 10x10 cm board that can contain a lot of stuff – I had 6 different PCBs on it).

I think of it as levels, defined for myself:

Level 0 - Blink on Arduino.

Level 1 - something useful on a breadboard.

Level 2 - your own kitchen-made PCB for something useful.

Level 3 - your own factory-manufactured dense PCB for somehing useful. <- I'm here

Level 4 - explore the wondrous world of 32-bit ARM or any other non-Arduino controller and do something useful with it (and, more importantly, something that will actually gain from ditching Atmega328).

The biggest problem is thinking up something meaningful to do. That's why a lot of people never go above Blink ('Look, I made this cute 2-LED RGB rainbow and this motor-driven spindle with bunny on top!' – 'Wow! What for?' – 'Hm... Beer, anyone?'). That's where you start, and then, once you have a firm idea of what you want, Google help.

But no one can give an advice on this meaningful idea, it's yours fully. Being a journalist and an artist, I decided to mix microcontrollers with art. You may find inspiration in your own field. Just remember – if the project you have in mind is already present on IKEA shelves (or in eBay/AliExpress stores), it won't keep you for long.

Don´t connect the arduino 5v with the 12 vdc input of the mini lead repeater/amplifier, this cause you will burn the arduino.

SOLVED - TL;DR place a 10-20k resistor between your output and the input; this works with logic level signals at 5v ** and 3.3v signal too!! **. I too struggled with these pesky amplifiers and finally opened one up to see what's happening on the inside. Here's the synopsis: An op amp (operating as comparator) drives the FETs. It compares to 4.7v for the switching. Each of the inputs has a 110k pull-up to high side (12v). Setting reference voltage equal (tying ground together) allows 5v Arduino to drive the amp. For the case of driving from a 3.3v micro you would run into the issue that neither 0v nor 3.3v are sufficient to switch the output.. however when you place a resistor in the middle it allows the input to be pulled up slightly - then you are toggling between.. let's say 3v and 6.6v which allows you to switch!! Note that nothing is tied to the "reference" in the input ( the one with the arrow ). In fact BE SURE NOT TO CONNECT TO REFERENCE because you are really just connecting to 12v from the power source - don't fry your board. Cheers mates! Happy hacking.

Where exactly are you saying the resistor should go?

More Comments