Electronic – arduino – How to switch a 12v line with arduino using a p channel mosfet when they have the same ground

arduinomosfet

I'm trying to turn on/off a 12v line using a Arduino and a p channel mosfet (f9540n), but if i were to connect them together using some simple schematics online, i would be sending 12v through the arduino. The supplies for the 12v line and the arduino have the same ground since im using the same power supply and a 5v regulator to supply the arduino. What options would I have to solve this? Is getting a n channel mosfet the only choice?

Edit: This is the diagram, I'm not really good at making them, but i hope it helps
enter image description here

Best Answer

Use This circuit.

Arduino will drive your MOSFET with the help of BJT at 5V safely.

schematic

simulate this circuit – Schematic created using CircuitLab