Flickering LCD on Project

Hello all! I’ve been working on a simple thermometer to use in my house. I wrote some code for it, simulated the circuit on AutoDesk, built the circuit part for part anddddd… the LCD is flickering. I have read other forum posts that didn’t really help me out either. I checked my connections numerous times and even went through the trouble of rebuilding the circuit again. Twice. I am kind of new to this, can anyone help? :sweat_smile:

#include <LiquidCrystal.h>
#define aref_voltage 3.3

int tempPin = 0;
int tempReading;

LiquidCrystal lcd (12, 11, 5, 4, 3, 2);

void setup()

{

lcd.clear();
//someone from another forum said that I should do this

Serial.begin(9600);

analogReference(EXTERNAL);

lcd.begin(16, 2);

lcd.print("Temperature: ");

}

void loop()

{

tempReading = analogRead(tempPin);

float voltage = tempReading * aref_voltage;

voltage /= 1023.0;

float TemperatureC = (voltage - 0.5) * 100;
float TemperatureF = (TemperatureC * 9.0/5.0) + 32.0;

lcd.setCursor(0, 1);

lcd.print(TemperatureF);

lcd.print(" F");

delay(5000);
//someone said that the refresh rate of the analog signal (coming off of A1)
//should be less than a few times a second for the LCD to “catch up”
//changing the delay didn’t really help, although I’d like to keep it
//around 1000 ms.

}

Thermometer.ino (950 Bytes)

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png? A picture of your project would also help.

Are you using the PC USB to power the Arduino, what model is it. What is your temperature sensor?

Do the LCD characters flicker, or the backlight flicker?

If you remove the temp sensor code from the sketch, does the flicker stop?

Thanks.. Tom.. :)

Oh sorry! Thanks for correcting me.

Here is the code:

#include  <LiquidCrystal.h>    
#define aref_voltage 3.3
 
 
int tempPin = 0;
int tempReading;

 

LiquidCrystal  lcd    (12, 11, 5, 4, 3, 2); 

void  setup()

{

 lcd.clear();
 //someone from another forum said that I should do this
  
  Serial.begin(9600);
  
  analogReference(EXTERNAL);
  
  lcd.begin(16, 2);
                          
  lcd.print("Temperature: ");  

}

void  loop()

{
  
  tempReading = analogRead(tempPin);
  
  float voltage = tempReading * aref_voltage;

  voltage /= 1023.0;
  
  float TemperatureC = (voltage - 0.5) * 100;
  float TemperatureF = (TemperatureC * 9.0/5.0) + 32.0;

  lcd.setCursor(0, 1);  

  lcd.print(TemperatureF); 

  lcd.print(" F"); 

 

  delay(5000);
  //someone said that the refresh rate of the analog signal (coming off of A1)
  //should be less than a few times a second for the LCD to "catch up"
  //changing the delay didn't really help, although I'd like to keep it
  //around 1000 ms.

}

This is the link to the simulation that I am working on.

The LCD backlight seems to be flickering. No visible sign of any of the 32 characters. I played around with the contrast potentiometer (10 K) and added resistance to the VCC, nothing seemed to work.
Hope this helps, thanks!

LCD and sensor sharing the same source maybe. Does unplugging the sensor stop the flickering?

Btw, how does that analogRead of pin 0 work? Is it assuming A0 for you, and why are you mentioning A1 in comments?

Sorry, I forgot to change that. It is A0, but it used to be A1. Sorry for the confusion

Hi, If its the backilight that is flickering then it has nothing to do with your code. The backlight is just a LED light that is powered from the arduino 5V, or do you have it connected to the 3.3V. Check what you backlight voltage should be.

The code has no control over the backlight.

Tom... :)

While that is all true, I assumed something could have been wrong with the code because the characters that should be there are not. The backlight is flickering, but no text is being displayed. Do you think I wired it wrong? I also added a 220 Ohm resistor between the LCDs backlight positive header and the 5v coming from the Arduino. I should mention that my sensor is running off of the 3.3v, and that both have separate GNDs. I have tried to switch them up, but nothing has seemed to work, thus far.

Hi,
Did you develop your code in stages?

First write and get the code for the display working and debugged.
then,
Write code for the temperature sensor, get it working and debugged.
then
Combine the two, get them working…

Have you tried the Example codes in the IDE for the LCD display?
Please a circuit diagram of what you have and a picture of your project so we can see your layout.

Yes possibly a wiring problem.

Tom… :slight_smile:

No such thing as separate GNDs

But anywho, I missed the part where you said no characters either. Thought everything was working other than flicker.

You need to show your setup, clearly show how you have it wired up.

The fact that you have your lib initialized with (12, 11, 5, 4, 3, 2) makes me wonder if you didn't just slap the LCD onto the board headers.

Don't want to be rude here, but you guys keep on asking for pictures. I put a link to the circuit diagrams and my simulation in my second post :)

If you missed it, here it is again: https://circuits.io/circuits/2559548-displaying-temperature-accurately-on-an-lcd-screen

If you need more, then I can try to draw it out. (And when I said separate GND I meant separate GND pins :sweat_smile:

Update:
I ran a sketch very similar to the “Hello World” sketch

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("  CODE MANAGER  ");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 3000.0);
}

The LCD seems to be flickering slightly faster, and the backlight is much brighter (it was relatively dim on my Thermometer sketch). I think that the sensor might be causing a problem, but I am still trying to test it all.

LCD_Sketch.ino (212 Bytes)

Back again, but this time I tested the sensor. The TMP36GZ seems to be working fine when I tried to display its output in the Serial Monitor.

void setup() {
  Serial.begin(9600);
  
}

void loop() {
  Serial.println(analogRead(A0));
  delay(500);
}

I used a very simple sketch. Also, the variation in the Analog Value was noticeable. When I touch the sensor it increased, when I opened a window in my room it decreased a bit.

If people keep asking for pictures of the setup, the logical conclusion is that it is because they want to see pictures of the setup. They're not asking for drawings or diagrams. Diagrams don't show the wrong things being hooked up.

ConstantineM:
Update:
I ran a sketch very similar to the “Hello World” sketch

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("  CODE MANAGER  ");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 3000.0);
}




The LCD seems to be flickering slightly faster, and the backlight is much brighter (it was relatively dim on my Thermometer sketch). I think that the sensor might be causing a problem, but I am still trying to test it all.

It would be helpful if you could be a lot more helpful. What do you see with this sketch? What do you see when you take out that junk in the loop?
To properly “test it all” and not waste everyone’s time, including yours, the very first step is to make your LCD show static text. Prove that everything is wired up correctly.

Sorry, I do not have a camera to take any pictures with. The best I can do right now is show you what it should be, and maybe give you a description of where I have the pins plugged in. Thank you for taking the time to help me out, I’m sorry if I need to be more descriptive.

I took out everything from the loop()

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  lcd.begin(16, 2);
  lcd.print("  ANYTHING  ");
}

void loop(){
  
}

No more flickering, however the screen does not print “ANYTHING”. Just a blank screen (with the backlight on).

Works for me. |500x281

Check every pin. * VSS- GND * VDD- 5V * V0- Out from potentiometer (contrast) * RS- Board pin * RW- GND * E- Board pin * D0-D3- Not connected * D4-D7- Board pins * A- 5V (backlight) * K- GND (backlight)

If it's wired correctly and the headers are soldered properly, then maybe you have bad wires. Last last conclusion is the screen is broken.

ConstantineM: No more flickering, however the screen does not print "ANYTHING". Just a blank screen (with the backlight on).

If you look at INTPs photo above and compare it to your display, do you see the darker non lit pixels that build the letters? If you don't see them the contrast setting is most likely way off and is a very likely to blame.

I grabbed a second breadboard and I spaced things out a bit. Everything seems to be working fine! Thanks for all of you're help, it seems that my project is complete.

Much thanks :)

Hi,
Did you have a protoboard with the two red and blue/bleck buss lines broken in the middle.
Check the picture below?
Protoboards.jpg
Tom… :slight_smile: