1

So I've tried with 3 different lcd screens and each one has given me something different (https://imgur.com/a/EVzFoVv) and here is my code

#include "LiquidCrystal.h"

// initialize the library by providing the nuber of pins to it
// LiquidCrystal lcd(8,9,4,5,6,7);
LiquidCrystal lcd(52, 50, 48, 46, 44, 42);

bool isSetup = false;

int want = 600;
int live = 615;

void setup() {
  lcd.setCursor(0,1);
  lcd.print("   Booting Up");

}
void loop()
{
  if(isSetup == false)
    Set();
}

void setupIs(){
  Clear();
  isSetup = true;
  lcd.setCursor(0,0);
  lcd.print("Want: ");
  lcd.setCursor(0,1);
  lcd.print("Live: ");
}
void Set(){
  lcd.begin(16,2);

// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print
lcd.print("WANT: 1500");
// set cusor position to start of next line
lcd.setCursor(0,1);
lcd.print("LIVE: 1800");
}

void Clear(){
  lcd.setCursor(0, 0);
  lcd.print("                ");
  lcd.setCursor(0, 1);
  lcd.print("                ");
}```
5
  • So now with your current code it works? How are we supposed to find the problems from before? Or is this the falty code? – chrisl Apr 9 '20 at 21:26
  • @chrisl The thing that isn't working is the lcd screen itself because for one of them, when I hit reset it goes from messed up to actually working for a second, then it gets messed up again. I am trying to fix that. I've tried different pins too – Alex S. Apr 9 '20 at 21:39
  • insert while (1) {} into your code ... it will basically stop the code execution at that point .... move it around .... try to find the location where the display shows legible text – jsotola Apr 10 '20 at 2:18
  • maybe you want to correct the title – Juraj Apr 10 '20 at 4:56
  • 1
    Your code is calling lcd.begin over and over and over in Set() from loop(). Surely that isn't good. You want to call begin ONCE in the setup function BEFORE you do any other commands to the lcd. You've got it printing in setup before you ever call begin. – Delta_G Apr 26 '20 at 7:01
0

Well first when looking at your code what you are essentially doing using the Clear() function is that you are writing something to the memory of your lcd screen again.If you really want to clear the display you could use lcd.clear().Try changing that. And make sure that your wiring is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.