Weird values using a Potentiometer

Hello !

I am currently testing some things with a LCD screen and a potentiometer.

However, there is a problem, the values displayed in the Serial monitor and on the LCD are not the same : for example, with 10 in the serial monitor, a 1089 is displayed on the LCD, or with a 975, a 9759 is displayed. I do not quite understand how it is possible...

Here is my code :

#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int Pot;

void setup() {
  lcd.begin(16, 2);
  lcd.print("Potentiometre");
  Serial.begin(9600);
}

void loop() {
  Pot = analogRead(A0);
  lcd.setCursor(0, 1);
  lcd.print(Pot);
  delay(200);
  Serial.println(Pot);
  }

Thanks,
Leo

Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE

The extra digits are still on the display from the previous value printed. Print spaces after the new value to erase them

1 Like

Well spotted!
Another cure would be lcd.clear(); before you print a new value.

Yes that is well spotted !

That is what I've done to finish, thanks so much to both of you !

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.