I have connected arduino nano every to my lcd display. It works perfect when i put all my code in setup() part. But when i put the code in loop() it does werid things. I have to put my code in loop(), because i am reading from load cell and displaying the values that are constantly changing. The delay can't be more than 250 ms.
This works well.
#include <LiquidCrystal.h>
int Contrast=30;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
analogWrite(6,Contrast);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("testing");
}
void loop(){
}
When I do this next thing it works well for few seconds and then it starts to display random weird characters and stops displaying anything after some time.
#include <LiquidCrystal.h>
int Contrast=30;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
analogWrite(6,Contrast);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
}
void loop(){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(millis()/1000);
delay(250);
}
I have tried removing lcd.clear() it didn't help. I thought it was a problem with wiring first, but it's not. What am I doing wrong?
Any help would be great, thanks.
What am I doing wrong?
... you are not debugging the code in a logical way ... first, display fixed text, such ashello world
and increase the delay time to something like 2 seconds ... that way you eliminate the possibility that the value of millis() is somehow messing up the displayed values ... it also allows you to use a stopwatch to determine how many iterations run before the problem occurs