The correct way to do pwm for LED intensity is
Connect the npn transistor via two 4k7 resistors
From a pwm pin of the controller. Emitter to ground
collector to 1k resistor yo 12v. Collector also to MOSFET gate. Mosfet's source to ground, and LED cathode to drain.
LED anode to 12v. For this apps, maybe it's better an irfz44 mosfet.
Ignacio
The potentiometer may be tied between 5v and ground, and the cursor yo an ADC input.
You'll need the software to convert from analog input to pwm output