P-Channel MOSFET as a Switch. Turn ON a 12V Motor with Arduino. (Step-By-Step Guide)

preview_player
Показать описание
This is a tutorial about using a P-Channel Enchantment Type MOSFET as a switch to turn ON and OFF a 12V Motor.

UPDATE:
You should also add a 100-ohm resistor between the Arduino pin and the Gate terminal of the MOSFET. The MOSFET has a small capacitance that starts to charge/discharge when you switch the Arduino pin. This creates a short current spike that can be bad for the Arduino pin. Especially if you plan to do high-frequency switching.

Diagrams and code:

I am using an IRF9540N, but you can use some other logic level P-Channel Enchantment Type MOSFET.

Disclosure: Bear in mind that some of the links in this post are affiliate links and if you go through them to make a purchase I will earn a commission. Keep in mind that I link these companies and their products because of their quality and not because of the commission I receive from your purchases. The decision is yours, and whether or not you decide to buy something is completely up to you.

Music from Youtube library.
Рекомендации по теме
Комментарии
Автор

AFTER 4 YEARS OF UPLOADING THIS YOU ARE STILL HELPING!!

leynardvillagracia
Автор

Thanks Indrek for an amazing explanation.

You helped me to solve my 48hrs challenge with correct Mosfet wiring!
It's very difficult to simplify and explain stuff like this, really appreciate it!

denizsogutlu
Автор

If you connect the 12v to the arduino VIN pin, my understanding is that the regulator will provide 5v to the Atmel device. At that point you should be OK to connect the grounds?? This is a question rather than advice. I would also recommend using a NPN transistor to to drive the MOSFET gate, with the collector biased at 12v via 10k resistor, the emitter connected to ground, and the base going to the arduino via a 10k resistor.

shabbee
Автор

Connecting the Arduino 5V to the 12V supply really threw me off at first. But I realize you are basically using that as the Reference instead of letting Ground be the common reference point. This way when the arduino output is Low (0V from the Arduino perspective) it is -5V on the Gate with respect to the Source. When Arduino output is HIGH (5V from Arduino perspective) then the Mosfet sees 0V at the gate with respect to the Source. You went over this at ~55 seconds on the Video, but seeing 5V connected to 12V throws me off until I remember voltage would be relative and depend on the common reference point which doesn't Have to be 0V/Ground. We're so used to connecting Grounds to make everything relative to 0V Ground, it seems backwards to leave grounds disconnected for circuits to act relative to the High Side instead.

marcov
Автор

very good, your the first that I can understand what is going on with these p and n mosfet's
👍

greggable
Автор

I added 1 component to the circuit and could do away with the Arduino, exactly what I was looking to do!
Thanks again Indrek

greggpierce
Автор

Could you use a photocoupler (opto-isolator) like PC817 to drive the MOSFET and eliminate the problem with sharing grounds?

JacobStevenson
Автор

sir, I connected 5v Arduino to source in minutes 3, the Arduino emitted smoke

bakulplastik
Автор

Can we use analogWrite 0-255 ? In P channel mosfet . I thought that use negative to work in gate

fredd
Автор

lets say te power supply for motor is 60 volts, would this circut still works ?

HS-hzfx
Автор

If my motor runs with 5v then I can use the same power supply for the arduino and the mosfet/motor right?

bigmac
Автор

Well done video, Appreciate the efforts, you earned a sub, just please dont use music in your videos or atleast keep it very low

GameAndJokes
Автор

Your video is really comprehensive and helped me getting started with MOSFET driving, however i have a doubt about Arduino and it's ground, in case i needed to add sensors or anything that needs a ground with the configuration shown on the video would burn the Arduino? Even if the Arduino was powered with a different source to the motor?

brunoperezmedellin
Автор

its basically the same with the N-channel, but works differently. thank you!

dogeeatsveggies
Автор

That's a good video. Also thanks for the warning part :)

I recently saw that you can avoid that power supply problem by controlling the P channel mosfet with another transistor (like an NPN or an N channel mosfet). That way you have two isolated circuits

caffeinatedinsanity
Автор

Hi, nice video, Q: is there MOSFET as a switch, when gate has 0v it switches on, need for 12v ups router

awaazmatroko
Автор

Thanks for the simple video. I am still thinking that when the gate is given 0 volt then how Vgs is -5 volt?

muhammadbilal
Автор

thank you everything is well explained. However i have a question about the fly back diode what are its specifications ?

yassindahmen
Автор

Are there any driver chip for P Mosfet?

orides
Автор

Hi, if I want to use depletion type mosfet for this project, which component you suggest?

ozkantuzemen