I'm trying to come up with a good circuit from common parts that will allow me to set predefined contrast levels to the LCD from the microcontroller. I've seen an example on the internet but its for the PIC micro and it uses pulse width modulation.
I cannot afford to use pulse width modulation since I need to use my CPU cycles in the micro elsewhere.
So I thought of using a simple switch setup where depending on the value of the port pins, the contrast will be low, medium or high.
The maximum voltage that will enter the LCD as well as the micro is 5VDC. Eventually I will be running this circuit on batteries.
It is important that the display can produce clear text (not faint grey) when the battery level is very low (about 2-3V)
Question is, if this circuit setup is perfect, I would assume I could use 2N3905 for PNP transistors, but what about the resistors? Do I use some inverted voltage divider equation of some sorts?
I remembered in the past when I was playing with LCD's that when I hooked a resistor from the contrast to ground without initializing the LCD I see a bar of black squares (normal), but when I instead connected the resistor from contrast to VCC, I saw nothing. So that's why I asked if I needed some sort of inverted voltage divider equation to calculate the optimal resistor values.
Say the voltage level each battery produces is the following:
4V, 3.5V, 3V.
and in each of those cases, I want the display to be of maximum darkness without melting anything inside the display.
How do I choose the optimal resistor values?
And if my transistor setup is incorrect, how would I be able to improve that?