How to control external voltage via PWM

@ugfrog What you read is absolutely right, because N-Channel MOSFETs are made for high side switching (Load is connected to supply voltage). My updated schematic should work just fine. By controlling analogwrite() at the gate you can get a variable voltage at the load and the rest of the volatge would be dropped by the MOSFET. If required, use a heatsink with the MOSFET.

I had the same doubt :slight_smile: and I probably know the answer.

In a N-Channel MOSFET, conventional current (simply current) flow from Drain to Source. This is because electrons flow from Source to Drain. Source is named as source because it "sources" electrons and the Drain is named as drain because it "drains" electrons out.

Always remember that electron flows in the opposite direction of current flow.

Regards.