How to adjust the brightness of a small LCD(21V) with a potentiometer?
You will need a source of 22 volts. You could use a boost converter if all you have is 5V.
You need a high-side switch, this is not as easy as a low-side switch.



simulate this circuit &ndash; Schematic created using CircuitLab
The transistors are not critical, any small switching signal transistor should work.
The resistor values may need to be adjusted depending on how much current that the PWM input requires.