PWM with transistor and mosfet

Afternoon guys,
So I went away from my 5940’s which did not have the current capacity I needed and am currently using IRF510 mosfets to power my LEDs.
These are rated @ 5.6A and 100V.
I cannot seem to get PWM working through this setup while allowing full brightness of my LEDs. If I just digitalWrite them high and low they are full power, then when I try to analogWrite they will not pwm at all just stay on full with intermittent quick flash as if it went on/off extremely quickly.
I can only get the pwm to work when I put a resistor on the FET gate to common ground, but then the are only about 1/4 bright if not less. Have tried resistor values between 2.2k - 10k with no difference.

current setup:

Arduino > NPN Transistor gate (collector connected to external +12v, emitter connected to FET gate) > FET (mosfet source connected to common ground, Drain connected to LED negative side. LED positive side connected to external +12v.

very simple code just to make sure things work as they should.

int fadevalues[] = {0, 2, 6, 8, 11, 16, 23, 32, 45, 55, 64, 78, 90, 109, 128, 140, 162, 181, 200, 222, 255};
const int led1 = 10;
const int led2 = 11;

void setup()
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
void loop()
  for (int i=0;i<20;i++)
  for (int i=20;i>0;i--)

am currently using IRF510 mosfets to power my LEDs

These are not logic level FETs so you need 10V to turn them on fully. Use a logic level FET.

Modify your hardware setup: arduino - resistor - base npn transistor; emitter npn - ground. collector npn - resistor - +12V; collector - gate MOSFET;

Yes sir grumpy, I know they are not logic level thats why I'm running them off of the transistors. Yet even with the transistors switching +12v I can't get the full brightness with this setup and have PWM ability.

Magician: If I put +12v to the transistor collector and then run the mosfet gate to the transistor collector wont it just get a solid +12v at the gate not allowing for pwm?

You are not using the transistors correctly. As you describe it you will only ever get +4.3V on the FETs gate.

Re read what Magician said again. You had an emitter follower circuit you need a common emitter circuit.

You fooled me by saying there was something going into the transistor's gate, as a transistor has a base and a FET has a gate, you had made a mistake. I guessed at the wrong one.

My fault, I will give Magician suggestion a try.


I hooked up the circuit as you wrote Magician and I get full brightness but no PWM.

By collector - gate MOSFET; you mean NPN collector to MOSFET gate correct?

If you get full brightness but no PWM then you still have not wired it up right yet.

Yeas, check wiring again, is ground connected properly: arduino gnd - emitter npn - source FET - -12V power supply all together? Or post your schematics / hand drawn picture .

Well, I must be looking over something small thats messing me up cause I have checked the wiring multiple times and have found nothing wrong. Even had an EE friend take a look and he said it looks right.

Its funny cause without the resistor from the FET gate to ground it works full brightness but no pwm.
When I have a resistor from the FET gate to ground no matter what size pwm works but with no brightness.

Hopefully one day I will get a hang of these dang circuits. These are supposed to be easy too, Im just wiring up LEDs for gosh sakes.

Excuse the crappy schematic, my first time using Fritzing.

Those resistors are in the wrong place as we keep telling you!!!

The resistor should be from the collector to +12V. The gate should go to the collector as well. The emitter should go to ground as should the source.

Even had an EE friend take a look and he said it looks right.

Not much of an EE is he?

Here you are:

Have you a current limiting resistors in series with leds or it's 12V led strip with resistors build in?

Grumpy_Mike: Not much of an EE is he?

Looks that way eh..

Hooked it up exactly like the schematic and how yall have said. Still no luck. Going to try a different breadboard, seems I have no luck with breadboards.

Perhaps this will help --

When the Pin is Low, the Gate is High and the FET is On. When the Pin is High, the Gate is Low (at Gnd) and the FET is Off.

You could look into using a "FET driver" IC, but you should try and get this much right first.

Thanks for the help guys. Not sure where I'm going wrong. this is very frustrating, still have not got that circuit going properly. So I went out and got some logic level mosfets, using Fairchild FDP7030BL n-channel mosfets now.

I hooked up the circuit and was getting PWM yesterday but now today when I hook it up I get just constant full brightness no pwm.

Have a 2k2 across the gate and source on the mosftet then the gate of mosfet attached to pwm pin, source of mosfet attached to ground and drain to - side of LEDs with an external +12v to + side of leds. Grounds are together.

Changed the mosfet to an IRFIZ34EPBF and it works. WTF? Only thing changed was the type of mosfet. Tried multiples of the other and nothing.