Transistor/MOSFET not Working

Hi, I'm trying to control a common-cathode RGB LED strip with an arduino. The LED strip uses 12V, so I am trying to use an NPN transistor (2N2222A) to step the voltage up to 12V, which is then used to switch the MOSFET (IRF540), since the IRF540 needs 10V at the gate to switch.

This is my problem...
When I apply 12V to the gate of the IRF540 directly from the power supply, the LED strip lights, but when I try to apply 12V from the 2N2222A, the strip does not turn on. I'm not sure if it's a problem with how I've setup the 2N2222A of if something else needs to be done with the IRF540.

I've included my schematic and the datasheets of the transistors as attachments on this post.
Thanks in advance for any help.

Christmas LED Lights 1.PNG

IRF540.pdf (277 KB)

2N2222A.pdf (298 KB)

Basically, you have the 2N2222 configured as an emitter follower with the base tied to 5v - the best you will get out of the transistor like that is about 4.3v to the gate on the FET. What you need is the emitter to ground, a pull up resistor from the collector to the 12v and then drive the base of the 2N2222 through say a 1k resistor from the arduino to turn it on and off. Note that your control is now inverted - when the base of the 2n2222 is pulled up with the 1k resistor to turn it on, the collector will be pulled to ground so you have to invert your drive logic ("1" turns the FET off and "0" turns it on).

See THIS LINK for more info on using a transistor as a switch (which is what you are trying to do - switch 12v)

You seem to have the BJT set up as a high side switch, and the mosfet is wired backwards. There is no current limiting resister on the base of the transistor.

With the components you have, you are looking at having the leds on, and use the arduino to turn them off.

gpsmikey:
See THIS LINK for more info on using a transistor as a switch (which is what you are trying to do - switch 12v)

Looks like good info there! Although, their first circuit diagram at that link has a red line (connection between the signal input terminal and emitter). Doesn't look like they clearly explained what that red connection is for.

gpsmikey:
Basically, you have the 2N2222 configured as an emitter follower with the base tied to 5v - the best you will get out of the transistor like that is about 4.3v to the gate on the FET. What you need is the emitter to ground, a pull up resistor from the collector to the 12v and then drive the base of the 2N2222 through say a 1k resistor from the arduino to turn it on and off. Note that your control is now inverted - when the base of the 2n2222 is pulled up with the 1k resistor to turn it on, the collector will be pulled to ground so you have to invert your drive logic ("1" turns the FET off and "0" turns it on).

See THIS LINK for more info on using a transistor as a switch (which is what you are trying to do - switch 12v)

Any chance I could get a diagram? :slight_smile:
http://www.schematics.com/account/signup/

You basically have two choices - either use a switch like in the link I gave (which inverts the control) or use a logic level MOSFET that can be controlled by the 5v directly. I have a bunch of IRL520's that I use around here, but there are many newer ones with much lower on resistance - see what others have posted in the forums for part numbers. As another person noted, you also have the MOSFET backwards if it is wired as you show in your drawing. The easiest way is to use a logic level MOSFET driven from the Arduino through a gate drive resistor (with a pull down so that when the Arduino first come on before the output pin is configured for output, the MOSFET is turned off). Search the forums here for "gate drive resistor" if I remember correctly for some of the threads.

Here is another link that is along the lines of what you are asking.

The only problem with logic level FETs is they're quite expensive, and the ones that aren't are mostly SMDs (Surface Mounted).

I really don't understand why I'm only getting 4.3v from my 2N2222...
It doesn't make much sense to me

The reason you are getting 4.3V is that you have an emitter follower, the emitter is a diode-drop
below the base.

That is not the circuit to use for switching, its only boosts current and is usually used to turn
a high impedance analog signal into a low impedance analog signal.

emitter to ground, arduino pin via a resistor to the base. The collector is the switched output.

This simple circuit uses inverted logic. HIGH (5V) turns OFF LED strip, LOW (0V) turns ON LED strip.

dlloyd:
This simple circuit uses inverted logic. HIGH (5V) turns OFF LED strip, LOW (0V) turns ON LED strip.

Thanks for the reply :slight_smile:
Although, wouldn't grounding this circuit through the Arduino mean that there is 12V going through the Arduino, which is bad?

DibDibs:
Although, wouldn't grounding this circuit through the Arduino mean that there is 12V going through the Arduino, which is bad?

No. Volts never go through, volts are across.

The transistor base is one diode drop higher than ground at most. So its the Arduino
that is suppling a larger voltage, which is why the base resistor is needed to avoid
too much current flowing to the base.

The Arduino Gnd and the 12V Gnd get connected together so the everything has the same reference.
The Gnd connection lets the 12V current get back to the 12V power supply.

OK, I'm testing it now and the lights are just staying on.
I provided the wrong datasheet for the 2N2222A, I provided the datasheet for the P2N2222A, I am using a regular 2N2222A, will that make a difference?

Use a voltmeter to verify the drive to the 2n2222 is changing as expected. Verify the gate voltage on the FET is changing as expected (you did wire the FET correctly didn't you - it was shown backwards earlier). One would expect the output of the Arduino to be either 0 or 5v (or relatively close) depending on "on" vs "off" and the gate voltage on the MOSFET to go between "0" and "12v" or at least close to those values.

OK, I'm testing it now and the lights are just staying on.

Yes, the lights will stay on as default, because it's an inverted control circuit. Making the control signal HIGH will turn OFF the LED strip.

OK, I've got that circuit setup and the lights are turning off fine if I ground the gate pin of the IRF540, but the 2N2222 doesn't appear to be working, when I give the base of the 2N2222A 5V, the lights do not turn off, they remain on.

What could be the problem here?
Sorry about my naïvety, I haven't had much experience with MOSFETS and transistors.

If you give the base of the 2n2222 5V it will fry immediately. The base resistor is essential to
the circuit.

DibDibs:
OK, I've got that circuit setup and the lights are turning off fine if I ground the gate pin of the IRF540, but the 2N2222 doesn't appear to be working, when I give the base of the 2N2222A 5V, the lights do not turn off, they remain on.

Perhaps you should post EXACTLY how this is wired up. The IRF540 is an N-ch mosfet. You do not ground the gate to turn them on. A ground on the gate is to turn it OFF

tinman13kup:
Perhaps you should post EXACTLY how this is wired up. The IRF540 is an N-ch mosfet. You do not ground the gate to turn them on. A ground on the gate is to turn it OFF

reread the post: ''the lights are turning off fine if I ground the gate''

But yes I'm worried the NPN's base was shorted to 5V rail and destroyed.

I think he meant "base resistor" (if he followed the diagram). Here's how to identify the pins of the transistor: