I built a N-ch mosfet circuit for various loads using IRF520N and a low power transistor BC548C(NPN).
Altrough it works and is sensible enough to turn a 50W lamp on just when i touch input an '+' end,on arduino it won't work even if they are powered by the same 12V 4.5 A Pb-acid battery.This is the program i used for testing (i tried pin 11,12) and the eagle schematic with values. Arduino board works fine .
Thank you .
Hope it can be seen.
It's in Eagle window snip.
Bjt resistence(resistor)=470 ohm.
Gnd-gate resistence(resistor)=18kohm
gate-emmiter resistence(resistor)=330 ohm
The IRF520N is not a "logic level" mosfet. Now you have to increase the gate voltage.
The transistor won't work, since the base voltage is the output voltage of the Arduino pin (5V). You need a PNP transistor to increase the gate voltage. But it is better to use a "logic level" mosfet.
IRF520N is N-channel MOSFET.
Use 1K pullup to +12 to turn it on.
Use NPN with emitter to Gnd, Collector to the MOSFET Gate to pull Gate low to turn it off.
I can't find a schematic with PNP, and I can find a lot with NPN, like this one (figure 1) : Tahmid's blog: Low-Side MOSFET Drive Circuits and Techniques - 7 Practical Circuits
The drawback is that when the Arduino is turned on, the transistor is not active yet, and the mosfet will turn on. In many cases that is not a safe design.
(I think figure 1 is the same as CrossRoards mentions)
Or do you have an optocoupler ? An optocoupler with resistor to turn it on with Arduino output pin, and the the output from 12V to gate (with two extra resistors).
It may sound a bit stupid but how do i output '-' voltage(drive the NPN) in this case (NPN has 1k to+5 v) like CrossRoads sugested?
Can i write "analogWrite(-255);"?