I am trying to dim a 1w led (3v 350ma max) with a pwm signal from the arduino. I have a simple circuit using a 1k resistor on the base pin of a 2n2222 NPN transistor with the emitter connected to ground on the arduino and the collector to the negative terminal of the led. The positive led terminal than goes to 5v on arduino.
This circuit works perfectly fine and I am able to get it to dim correctly, however, I need to run the leds from a separate 5v power supply (walwart) while still controlling the base pin with the arduino. For some reason every time I replace the ground and 5v from the arduino with the ones from the walwart, the led will not light while using the arduino pin to control the base. If I connect the base to the positive terminal of the walwart the led will turn on.
I do not have a great understanding of circuit design as of yet and feel like I am missing something small so any help would be greatly appreciated!
Thank you very much it is working perfectly now!
I'm glad I learned that, it makes a lot of sense!
I am mainly testing this with two double A batteries as its closer to 3v, but at first I was using the 5v walwart with a 10ohm resistor and it seemed to be okay for the short tests I was doing. I will be buying a 3 volt walwart to run them as together they will take upwards of 1.4 amps.
This is ultimately for moon light control for a reef tank. I was planning on having four 1w leds wired in parallel each individually dimmable to simulate to lunar phases and cloud cover.
I am also wondering, would it be better to run the leds off of a 3volt walwart or to get a 3.3volt voltage regulator to convert a 5v supply? I am guessing the voltage regulator would be a lot more stable, yes?
I appreciate your help, I still have a lot of learning to do on the hardware side!
OK, next thing to learn is that LEDs don't work well if you try to control their voltage, they work much better if you control their current. If your LEDs need 350mA then you need a special "constant current" circuit that allows that many amps to pass.
The reason is that LEDs don't have a constant resistance, their resistance varies with voltage. Even tiny errors in voltage can lead to big errors in current, enough to damage the LED. Every LED is slightly different and needs a slightly different voltage so the only way to avoid those errors is to control the current.
You can get a special "led driver" for this or look for examples in these forums.
I did know this already and have a constant current driver that will supply voltage to one or all of the leds, that was actually the first ting I tried to dim them with before the 5v source. Since it didn't work as I did not provide the common ground I just assumed that the constant current driver just pumped out more current to compensate for the dimming and keep the led at its max.
I just hook up the circuit with the constant current driver and it is all working as it should, thank you very much!
If you know of place off the top of your head, is their a website that provides basic electrical knowledge and covers a wide basis of topics?
I noticed that when I keep the led at 350mA, which I tested with a meter, the 2n2222 transistor gets very hot very quickly. So since this is too much current for the npn's can I use a TIP120 Power Darlington Transistor from adafruit for the job?
I've used the 3W and 10W version of these guys forever (direct arduino PWM drive)... ebay #380519501055
All you need then is say a regular 19v laptop power supply for about $5 and you're golden.
Personally, I use a butchered computer power supply and run strings of 3 at a time
The reason why your 2N2222 gets hot is that it has a high saturation voltage (up to 1.6V @ 500mA from the datasheet). You need a transistor that has high current gain and low saturation voltage at 350mA. A ZTX851 would be ideal. Even a BC337 would be run cooler than the 2N2222. You can certainly use a mosfet instead, but you do, look for one with logic level gate drive, not the IRF510 (which is designed for 10V gate drive).
So the switch-mode constant current drivers shouldn't be pwm'ed?
So are you saying the ZTX851 would be better to use than a logic level mosfet but still not better than getting a constant current source with a dedicated pwm pin?
Can I build this circuit instead of buying a different pwm constand current driver?
Note: A switch-mode driver will be more efficient in terms of power use than the MOSFET circuit - something to think about if it's running 24/7 (the MOSFET circuit turns the excess volts into heat!)
a) yes
b) both the ZTX851 and the logic level mosfet are good solutions at this sort of current
c) yes. Use the lower of the two schematics. Calculate how much power the mosfet will dissipate, which is (V_supply - V_leds - 0.65) * I_leds, and provide the mosfet with a sufficient heatsink.