generating potentiometer adjustable, non-inverted voltage square pulses from microcontroller gpio output
Another option is simply an N-MOSFET. 99.9% of the time you can do the inversion in the MCU itself and remove U1, but on the off-chance that you can't for whatever reason, add an inverter U1. Also, restrict your pot range by adding lower and upper fixed resistors:



simulate this circuit &ndash; Schematic created using CircuitLab
An even simpler option is to replace both the inverter and the MOSFET with an open-drain (or open-collector) 12V-tolerant non-inverting buffer.