I am on my way to learn how to use arduino and so i hit many minor difficulties, right ow i met one i am not sure how to fox properly
I want to write a moving variable to one of my lcd rows but over a set value i want the text or in this case numbers to change,
the problem i had was that when it changed back i had the last column stop on the last digit and stay there instead of resetteing to nothing.
therefor i added the lcd.clear(); command in the loop to reset and remove the digit. Now the second problem comes the numbers flicker constantly because of this code, how do i implement this code so i dont get the flickering?
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);
lcd.setCursor(0, 0);
if (voltage < 2.5)
{
lcd.clear();
lcd.print(sensorValue);
}
else {
lcd.clear();
lcd.print(voltage);
}
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}
Position cursor where you want to display voltage value. Print spaces to blank out the existing data. Reposition cursor in the same position and display voltage value. No need to clear display.
In future please use code tags - see the sticky on 'How to use this forum' at the top of the page.
1: don't update as often, once a second is usually enough (unless you want to see second tenths, for example)
2: don't use lcd.clear() as it is first, blocking in nature and second, it takes a long time.
Thank you, that was excatly what i needed. it was enough to use the line for the smaller number for practical purposes but the flicker and ekstra number is gone
BulldogLowell:
there are two ways to get rid of that flicker
1: don't update as often, once a second is usually enough (unless you want to see second tenths, for example)
2: don't use lcd.clear() as it is first, blocking in nature and second, it takes a long time.
something like this perhaps:
void loop() {
static unsigned long lastTime = 0;
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1023.0);
Serial.println(voltage);