Thanks! This indeed ended the “lag”. However, plugging to VO pin directly to GND is way to much backlight, so I must restrict it, which I’ll probably do with a 390R or similar.
You suffer from a couple of very common matters of confusion here. The backlight is the LED powered by the 420 Ohm resistor. You can if you wish, switch it on and off to conserve power by connecting it to an Arduino pin and you could even dim it using PWM, but generally you only need a choice of three brightness levels; fully on, dim for night use, or off, and these can be set using resistors. The LCD board usually contains a 100 Ohm (“101”) resistor at R8 to set the LED current which allows it to be directly controlled by an Arduino pin.
A pot could also work, however, one of my goals in the project is to have a very minimalistic approach (thus I am using a Nano and not a UNO).
“Vo” sets the contrast of the display. This requires a voltage of between 4.5 and 5 V negative to Vcc for the common display materials (significantly greater however, for those designed to work is extreme cold). When the original chip was designed many years ago, one “test” circuit was published with a potentiometer to set the voltage and in a fascinating blunder, engineers ignored the other design information and ever since imagine a potentiometer is necessary. In fact, what is required is a resistor, fixed or variable, from Vo to ground. Since the chain of resistors internal to the display board total 11k, (five times 2k2) a resistor of up to 1k to ground is just about right.
What does not work, is connecting this to a PWM output; the results are entirely random and will cause the exact sort of effect you describe.
Also, how did I not quote my sketch? Sorry if I misspelled something or have a mistake in the sketch, but I don’t understand/see where.
In the Arduino IDE terminology, it is the source code that is called a “sketch”. Asking for your “sketch” is asking for you to post your code using the “code” (
</> icon at the top of the “Post Reply” window) macro.
It is still a mystery why this worked in the UNO but not in the Nano.
No, the mystery is why it ever functioned if you drive the contrast chain with PWM. What happens is a complex interference between the PWM waveform and the multiplexing frequency of the LCD driver. Whether it is visible at all is a fluke.
If you do not wish to include a variable resistor, just use a 390 or 470 Ohm resistor between Vo and ground. Try one and the other, and use what looks best. Note however that if your Vcc varies, so will your contrast, no matter how you connect it. Unfortunately, every so often, someone confuses PWM with a variable voltage and if they are really unlucky, it actually works and they write it up on “Instructables” or some similar site to entrap newbies.