Issue with my monochrome LCD

Hello guys;
I'm trying to display some text on a monochrome LCD (16x2). When I run the code, it has a strange effect like the rows of pixels are taking turns being lit up or not. Sorry I cant share how it looks like. Does anyone have any idea whats happening? Thanks so much!

#include <LiquidCrystal.h>
int Contrast=145;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  
 
 void setup()
 {
    analogWrite(6,Contrast);
     lcd.begin(20, 4);
  } 
     void loop()
 { 
   lcd.clear();
   lcd.setCursor(0, 0);
   lcd.print("Hello");
   delay(1000);

   
 }

(my code)

Without seeing an actual picture of the issue on the LCD, my initial guess would be contrast adjustment. What does the datasheet for the LCD module say about contrast adjustment? There's usually a pin that you connect to an external variable resistor so you can vary the contrast by hand.

We are sorry too as without that detail we really cannot make any suggestions. :worried:

Ouch. Why does anyone ever do this ? PWM does not work.

You can connect VO on the lcd directly to GND with a fixed resistor e.g. 470R. Much neater and simpler than random wires, potentiometers, ...

You will get a "visible" display for any value between 0R and 1k0.

David.

Oh! Good pick! I didn't notice that. Well done! :+1:

Set "Contrast" to zero! That is not optimum, but works!

Why do they do it? "Instructables" is why (I think :crazy_face:)!

Well, I suppose PWM could work with sufficient low-pass filtering. i.e. extra Rs and Cs.

It just seems more work than a single resistor.
Let's face it. Everyone can make a 0R resistor. Most punters are allergic to capacitors.

David.

Hi @david_prentice @Paul_B
Could excuse my ignorance.

So that I can learn.

What does the "contrast" variable have to do with the LCD in this sketch?

RV mineirin

The VO pin on the 16x2 LCD controls the contrast. It is designed for a resistor that connects to GND (or a small negative voltage)

PWM is a 5V rectangular wave. The +5V pulse will upset the LCD controller.

David.

@david_prentice.

But where did the author say that he connected the LCd's VO to pin 6 of the arduino?

RV mineirin

It says new users cannot upload attachments??

I quoted the statement in #4

I don't know what the new rules are for the new Forum software.
It seems crazy to put upload restrictions onto new users. (However it would be sensible to allow someone who has read the Forum guidelines)

It would be even more sensible if you could find the new Forum "rules".
The old software had a sticky message in every Forum that showed you how to ask questions, get the best answers, ...
This general advice is still here but nowhere does it say "upload restrictions"

interesting

It is implicit in the

No it could not.

The resistors would have to be less than 50 Ohms in total (and the capacitors rather large), being the minimum contrast resistor value (and the approximate value of the Arduino output internal resistance when you set "Contrast" to zero) but then the Arduino output cannot safely drive them. It is a paradox.

You would use PWM as a charge pump to a Capacitor.
The VO pin has an effective impedance of about 10k.
The +ve pulses will "pump". The -ve pulses will discharge the Capacitor.
I would definitely have a series resistor from the PWM pin e.g. 5k0 giving an effective 3k3 impedance.

Untested. It seems a pointless exercise. Especially when you have to use an external series R and external C.

Perhaps I might calculate some real values and try it with real components. 3k3 with 1uF = RC = 3.3ms. Which sounds acceptable with a 10kHz PWM (period 0.1ms).

All the same. One resistor is easier, cheaper and safer. And is what HD44780 was designed for.

Modern TFT, OLED, ... controllers generate all their voltages on-chip. But they use higher frequencies and require smaller pump capacitors.

David.

It does indeed - but you require a resistance of less than 100 Ohms to pull it down to less than 0.1 V as you need to have adequate range of adjustment . Anything higher, it simply cannot pull it down to that level.

Even worse! The positive pulses are working against getting the voltage down to the necessary level and they are 20 times more effective in pulling the voltage up.

You would actually need a buffer amplifier to make it work.

I don't follow your argument. However it is my bedtime.

I will try it tomorrow.

Most 16x2 LCDs require about -4.5V relative to the VCC pin.
To cater for different units you might use a range of -4.0V to -5.0V relative to VCC pin. e.g. 1.0V to 0.0V relative to GND on a VCC=5V system.

If you run on a VCC=3.3V system, a simple resistor to GND does not work. You need a negative supply or a negative charge pump driven by PWM.

David.

Which is the position on the PCB and the solder links to fit the ICL7660 (or variant) on the LCD module.

[sujenvonmusk]
I think your'e lost in the contrast discussion. Use a resistor to gnd as mentioned.
You started saying an LCD 16x2, but you defined lcd.begin(20, 4); in your sketch???
Try the 'hello world' example in the developement tool.

hellooo... update: ive tweaked the connections and it appears to be fine, the strange effect is gone, but one thing: nothing is displaying