I have been trying to control the contrast pin using a PWM output from an Uno board, rather than from a physical pot. I found that when controlling V0 from the PWM this caused random characters to appear of the LCD after varying amounts of time, while controlling V0 from the physical pot caused it to be stable. After some hair pulling, I found the answer helpfully at: http://forum.arduino.cc/index.php?topic=91529.0
So to make the the LCD work properly, I stopped controlling the V0 contrast pin from the Uno board. Note that I still controlled the backlight from the Uno board, using a digital output pin, and this worked fine. More here if interested: http://makerself.wordpress.com/2014/12/08/getting-a-16x2-lcd-screen-to-work-and-developing-a-lcd-contrast-tester/
*My question is this*
What is it about the PWM output that causes this issue? And any thoughts on how to solve this? I would be very keen to have LCD contrast be adjustable by software, rather than hardware.
I am thinking of two potential solutions to 'clean' the PWM output, but am not sure if these will work as I am not sure what it is about the PWM output that causes these issue.
Option 1>>: put in a capacitor between the PWM output and ground, as maybe the PWM output has some spikes that need to moderated that are causing the issue.
Option 2>>: have the V0 pin (which controls the contrast) connected to a supply that is controlled by a transistor. This way, the PWM pin on the Uno can control the transistor gate (if MOSFET) or base (if BJT), which would adjust the voltage on the V0 pin. This is because I suspect that it is the variable nature of the PWM which causes the issue vs. the continuous current from the pot.
My questions are: 1) Any advice on how to do this (control V0 by software)? 2) Which of these options would be the better approach (or another approach that I have not thought of)? 3) If the transistor is the way to go, which of a MOSFET or BJT would be the best for ensuring a continuous current at the V0 pin?