How to control external voltage via PWM

Oh, very sorry my bad.

@ugfrog The GND symbol I showed you in the schematic is the High Voltage source ground. And Yes, you did it correct, you always need to have a common ground when using an external source of power.

Electronics is all about experimenting and this is why I love messing up with electronics and robotics.