LCD Dim

Hi guys, new here

Having trouble with my LCD screen. It's the regular 16x2 5V one that comes with the arduino Uno starter kit.

The background is lit up just fine. When I connect the contrast pin (3) to a potentiometer the words are only just barely visible at the minimum resistance. It looks the same when I connect that contrast pin straight to ground.

Weirdly when I quickly disconnect and reconnect the power it throws random words on the screen that are very bright and visible. But I can't seem to get it to do that for me normally.

Also, this was not the case with my Arduino Uno using 3.3V (it worked just fine). Now I am using a Dragonfly STM32L476 on 3.3V and I'm having this problem. Here's my code, very simple:

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 7, 5, 4, 3, 2);

const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;

void setup() {
lcd.begin(16, 2);
pinMode(switchPin, INPUT);

}

void loop() {
lcd.setCursor(0, 0);
delay(2000);
lcd.print("Pitch");
lcd.setCursor(0, 1);
lcd.print("Roll");
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
lcd.setCursor(0,0);
lcd.print("Max values:");
lcd.setCursor(0,1);
lcd.print("Pitch and roll");
delay(5000);
lcd.clear();
}
}
prevSwitchState = switchState;
}

Any ideas? Thanks!

Are you running the LCD at 3v? If so, run the LCD at 5v.
You don't need to run the LCD at 3v to interface with 3v processor outputs.
The LCD at 5v will still see logic H for a 3.3 v H signal output.

--- bill

Hi doodlestj,

First check the integrity of your LCD: reconnect it to your 'old' Arduino Uno and run the 'hello World' sketch for the LCD
then reconnect to the Dragonfly STM32L476
I checked your constructor (LiquidCrystal lcd(8, 7, 5, 4, 3, 2)). For the Uno, it is usually LiquidCrystal lcd (12,11 7, 5, 4, 3, 2).

Check your pin mapping table, can be found at https://www.tindie.com/products/tleracorp/dragonfly-stm32l47696-development-board/

Most LCDs require 5V for the contrast to work with a simple resistor to GND on VO pin.

It looks as if the VD0A pin on your DragonFly gets 5V from the USB cable. But you need to check this for yourself.

The LCD logic will operate fine at 3.3V. If you connect VCC to 3.3V you need a small negative voltage on VO pin.

David.

david_prentice:
If you connect VCC to 3.3V you need a small negative voltage on VO pin.

About 1.5 V in fact.

The 3.3V version of the "1602" display contains a charge pump IC to generate this additional voltage.

photoncatcher:
Check your pin mapping table, can be found at https://www.tindie.com/products/tleracorp/dragonfly-stm32l47696-development-board/

The pins used, even if incorrect, is not going to affect the contrast of the LCD.
doodlestj said he could see the words which means that pin mapping is correct.
you can't alter the contrast on this type of LCD h/w with s/w on the host.

The reason the pixels get bright after power is yanked is that the LCD reverts back to its default mode which is 8 bit mode and single line. The garbage is from the LCD being out of sync with the host on the interface so it is not seeing proper instructions.
In single line mode the LCD pixels get twice the duty cycle and will appear brighter given the same contrast input voltage than multi line mode.

Given the symptoms presented so far, it looks to me like a 5v LCD is being run off 3v instead of 5v.

--- bill

Scroll down on this link and you can see the pin out of my board:

I believe all of the pins 2-8 that I'm using are digital output which works

I don't think my board has a 5V? Correct me if I'm wrong. I would've assumed that the issue was that I'm using 3.3V but when I connect everything to my Uno at 3.3V the LCD works fine

bperrybap:
The pins used, even if incorrect, is not going to affect the contrast of the LCD.
doodlestj said he could see the words which means that pin mapping is correct.
you can't alter the contrast on this type of LCD h/w with s/w on the host.

The reason the pixels get bright after power is yanked is that the LCD reverts back to its default mode which is 8 bit mode and single line. The garbage is from the LCD being out of sync with the host on the interface so it is not seeing proper instructions.
In single line mode the LCD pixels get twice the duty cycle and will appear brighter given the same contrast input voltage than multi line mode.

Given the symptoms presented so far, it looks to me like a 5v LCD is being run off 3v instead of 5v.

--- bill

This is good info. I changed my code to set up the LCD as only one line and the contrast is great...

So how can I keep this with two lines? I'm unsure how to give V0 negative voltage

doodlestj:
This is good info. I changed my code to set up the LCD as only one line and the contrast is great...

So how can I keep this with two lines? I'm unsure how to give V0 negative voltage

You can't.
As the LCD chip has to drive more rows of pixels it takes more time .

doodlestj:
I don't think my board has a 5V? Correct me if I'm wrong. I would've assumed that the issue was that I'm using 3.3V but when I connect everything to my Uno at 3.3V the LCD works fine

Measure the actual voltage being fed to the LCD. I'm guessing it is a little bit higher when using the UNO.
As the voltage gets lower on the 5v lcd, the contrast voltage will also drop and at some point you will need a negative voltage to get good contrast.

You likely will need a 3v LCD device for this unless you can generate the negative voltage.

--- bill

bperrybap:
You can't.
As the LCD chip has to drive more rows of pixels it takes more time .

Measure the actual voltage being fed to the LCD. I'm guessing it is a little bit higher when using the UNO.
As the voltage gets lower on the 5v lcd, the contrast voltage will also drop and at some point you will need a negative voltage to get good contrast.

You likely will need a 3v LCD device for this unless you can generate the negative voltage.

--- bill

I measured the voltage (at the microcontroller, do I need to measure it at the LCD?) and both Uno and Dragonfly were 3.26V

Can you explain how to get a negative voltage to the V0 pin? Or also if you know a good 3V LCD I might just buy that

Or does my board have 5V? I see a pin labeled "VDDA" but don't know what that is. I suppose I could try it, hold on, have to get back to work

Sorry I guess I was wrong - when I measure the voltage with the Uno it's 4.1V and 3.26V with the Dragonfly. If that's the problem then I guess I need a 3V LCD screen

^Thinking to go with this one

doodlestj:
Sorry I guess I was wrong - when I measure the voltage with the Uno it's 4.1V and 3.26V with the Dragonfly.

4.1v on the 3v Arduino pin?

bperrybap:
4.1v on the 3v Arduino pin?

Yep reads 4.1V on the 3.3V arduino pin

doodlestj:
Yep reads 4.1V on the 3.3V arduino pin

And this is when running the UNO at 3v?

If the UNO was at 5v then yes 4.1v is too high for a 3v power level.
However, you should not be running the LCD at a lower voltage than the output signal voltage of the processor.
i.e. if the processor is outputting 5v signals to control the LCD then the LCD needs to run at 5v.

--- bill

May I modestly suggest an 12832 or 12864 OLED display with i2c interface? 3.3V and only two data wires. easy to impklement

bperrybap:
And this is when running the UNO at 3v?

If the UNO was at 5v then yes 4.1v is too high for a 3v power level.
However, you should not be running the LCD at a lower voltage than the output signal voltage of the processor.
i.e. if the processor is outputting 5v signals to control the LCD then the LCD needs to run at 5v.

--- bill

Yes I have the wire coming from the 3.3V pin on the Uno

You should have the LCD module powered from the 5 V, not the 3.3 V. :roll_eyes: