Go Down

Topic: Controlling simple RGB LED-strip with transistors instead of relays? (Read 226 times) previous topic - next topic

felic

I have a simple RGB LED-strip that operates at 3-24V (the LEDs are not individually addressable). It's made out of 30 LEDs (5050 smd).
I was at first planning to control it directly from an Arduino using 3 analog pins, but from what I read you should not draw more than 40mA from any pin. But the strip draws about 18.5mA per color of a single LED at 5V. So all 3 colors on all 30 LEDs lighting at the same time makes 18.5mA*3*30=1605mA.

So my next idea was to control 3 relays with the Arduino and these relays would sit directly between the power source and the LED strip. But relays are annoyingly loud and the ones I have are too big imo.

So I thought: maybe transistors..
I have quite a lot of different transistors lying around, but I have no experience in using them at all. I know all the theory, but when it comes to the specsheets I'm completely lost.


I will power the whole thing with one or more LiPo batteries and potentially a boost converter.

My question is: can I replace the relays with any of the transistors I have at home?  
Transistors:

BS170, BD139, IRLZ34N,
S9012, S9013, S9014,
S8050, S8550, 2N3904,
2N3906, BC327, BC337,
Tl431, MPSA42, MPSA92,
A1015, C1815, 13001

And in case that matters:
I have resistors with every imaginable ohm value.  
I also have a big kit of polyester film capacitors ranging from 470pf to 470nf.

felic

After hours of searching it turned out to be really simple using BS170. I uploaded a little example project to GitHub: https://github.com/T-vK/LedStripController  

Now I can easily control each color!

Basically, this is my circuit:


And my test code: 
Code: [Select]
const int red =  10;
const int green =  9;
const int blue =  8;

void setup() {
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
}

void loop() {
    digitalWrite(red, HIGH);
    delay(50);
    digitalWrite(green, HIGH);
    delay(50);
    digitalWrite(blue, HIGH);
    delay(50);
    digitalWrite(red, LOW);
    delay(50);
    digitalWrite(green, LOW);
    delay(50);
    digitalWrite(blue, LOW);
    delay(50);
}

Wawa

Circuit is ok, mosfet choice is wrong for the current you're talking about.
Didn't look through all the mosfets in your list, but the IRLZ34N would be perfect.
With bigger mosfets, it's wise to use a 220ohm resistor between Arduino pin and gate, to limit switching currents. And a 10k resistor from Arduino pin to ground, to have the gate firmly grounded during bootup.
Try analogWrite to control the brightness of your LEDs (PWM pins only).
Leo..

felic

Thank you for your answer, I appreciate it!

In the specsheet it says 500mA for continuous drain and 1200mA for pulsed. 
Is that why the choice was wrong? 
Because if I would run my circuit at 12V I would be way below these limits. 


What exactly do you mean by "a 10k resistor from Arduino pin to ground" should I connect my output pins to the gnd like that or should I put a resistor between the power source and the gnd pin? 


Wawa

Look at the graphs in the datasheet for 5volt Vgs and the voltage/current that goes with it.

As said, use 10k 'bleed' resistors from Arduino pins to ground.
When the Arduino starts up, all pins are inputs/floating/high impedance.
A 'floating' gate could turn on the fet.
Leo..

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy