Do certain pins on a 16x2 LCD need PWM?

Hello all I know it's possible to use different digital pins for the lcd but do certain pins need to be connected to a Digital Pin with PWM?

PWM is not used for any of the pins for the display. The exception might be the backlight if brightness control is desired. Why do you ask?

You can use any available I/O pin (that includes the so called 'analog' pins) on the Arduino to drive any of the pins on the LCD.

You inform the LiquidCrystal library about the pins you have selected by means of the numbers in the argument of the 'constructor' which is the [color=blue]LiquidCrystal lcd(. . .);[/color] statement.

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
  LiquidCrystal lcd( 7, 8,  9, 10, 11, 12);      // put your pin numbers here

Not only is PWM not required, the microcontroller itself is not required. You can run the display with a battery, some wires, and a bunch of switches. EDIT: How to do it.

Don

RandomExplosion:
Hello all I know it's possible to use different digital pins for the LCD but do certain pins need to be connected to a Digital Pin with PWM?

I do trust you are not getting confused by a completely misleading suggestion seen in some places (dare I say, "instructables?") that you can use PWM to set the contrast voltage "Vo" on pin 3.

This is complete nonsense. "Vo" on pin 3 should connect to ground by a resistor or variable resistor of between zero and 1k, nothing else.

floresta:
You can use any available I/O pin (that includes the so called 'analog' pins) on the Arduino to drive any of the pins on the LCD.

A6 and A7 on the Arduino Pro Mini are analogue only.

srnet:
A6 and A7 on the Arduino Pro Mini are analogue only.

I believe they are also input only, hence not I/O.

Don

srnet:
A6 and A7 on the Arduino Pro Mini are analogue only.

Pro Mini and Nano - one of the reasons why the Nano is superior to the UNO for "real world" applications.

floresta:
I believe they are also input only, hence not I/O.

Well, "analog only" defines input only, since there are no analog outputs on an ATMega in any case.

Just a worthwhile reminder. :grinning:

Paul - This is why, in my reply (#2), I used the 'so called' terminology and put the term 'analog' in quotes. I was emphasizing that this is an Arduinoese description of the pin function.

Don

Paul__B:
I do trust you are not getting confused by a completely misleading suggestion seen in some places (dare I say, "instructables?") that you can use PWM to set the contrast voltage "Vo" on pin 3.

This is complete nonsense. "Vo" on pin 3 should connect to ground by a resistor or variable resistor of between zero and 1k, nothing else.

That is a bit harsh. It is possible to use PWM to control LCD contrast, but a low pass filter (as simple as an RC network) should be used to smooth out the PWM signal into an analog voltage rather than trying to control the contrast with a digital PWM signal using an Arduino PWM pin directly connected to Vo.

At some point I'll be including support for contrast control along with documentation for how to create the needed added circuitry in the hd44780 library package. (the needed underlying API low level support is already there)

--- bill

bperrybap:
That is a bit harsh. It is possible to use PWM to control LCD contrast, but a low pass filter (as simple as an RC network) should be used to smooth out the PWM signal into an analog voltage rather than trying to control the contrast with a digital PWM signal using an Arduino PWM pin directly connected to Vo.

Possible, but to what value? That is why I am so didactic. Just one resistor sets the value, why add a capacitor and waste a MCU pin?

The contrast is not a "control" as on a TV (though frankly I cannot recall setting it on a TV for some years either); it is absolutely "set and forget"; it has an optimum value (since the display is not grey-scale). If the supply voltage (or temperature) changes, the contrast will change, but I cannot see how software control can in any useful way compensate for this.

Paul__B:
Possible, but to what value? That is why I am so didactic. Just one resistor sets the value, why add a capacitor and waste a MCU pin?

The contrast is not a "control" as on a TV (though frankly I cannot recall setting it on a TV for some years either); it is absolutely "set and forget"; it has an optimum value (since the display is not grey-scale). If the supply voltage (or temperature) changes, the contrast will change, but I cannot see how software control can in any useful way compensate for this.

You are incorrect that it is always "set an forget".
As you mentioned there are real world cases where the contrast must be re-adjusted.

I have seen many cases during my LCD backpack testing where I move a device from different power sources and the LCD contrast changes quite a bit and must be re-adjusted by rotating the pot on the backpack.
Moving from the "Arduino" from being powered by USB to its pre-regulated voltage input or when using batteries.
The contrast can change enough to make the LCD very difficult if not impossible to read but readjusting the pot corrects the issue.

There are also cases where the viewing angle significantly changes and the contrast needs to be adjusted to compensate.

Having the ability to adjust it in s/w allows the human viewing the display to adjust the contrast for these changing situations.
This could be extremely valuable when the LCD and h/w is in a more closed system.
Think a battery powered portable device that is in a case. In that situation the batteries will be draining causing the contrast to change, potentially to unacceptable levels.
Having a the ability for the user to re-adjust contrast in this type of device can be quite beneficial.

I have several portable electronic devices that work this way, including an old GameBoy from the 90's.

--- bill

bperrybap:
Having the ability to adjust it in s/w allows the human viewing the display to adjust the contrast for these changing situations.

Presuming they can navigate the menu to the part where you control the contrast.

If you want that ability, there is much to be said for a 1k variable resistor.

Paul__B:
Presuming they can navigate the menu to the part where you control the contrast.

If you want that ability, there is much to be said for a 1k variable resistor.

Not really disagreeing with that;
but I was originally responding to your rather harsh comment:

"Vo" on pin 3 should connect to ground by a resistor or variable resistor of between zero and 1k, nothing else.

which seems to be presuming a given form factor and/or implementation for the project/product.
There are many real-world applications/products that allow for contrast adjustment through some sort of user interface rather than provide access to a potentiometer as the device maybe be sealed up or in a location that makes access to a pot difficult or impossible.
For those situations having an analog voltage controlled by s/w can be quite useful.
With an arduino, it can be done using 1 PWM pin and a simple RC network to convert the digital PWM signal to an analog voltage to feed into Vo.

--- bill