So I have a 2 x 16 sainsmart LCD and I am just playing around with it. I have successfully mapped down the potentiometer reading to a number from 1 - 10 and it is displayed on the LCD. The problem is that the potentiometer is constantly being read by the program and hence fills up the display when I only want one character to be used.
How can I tell the arduino to stop the analogReading when the potentiometer is not being changed?
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
const int potPin = A0;
int currentPotValue;
void setup() {
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0,0);
}
void loop() {
currentPotValue = map(analogRead(potPin), 0, 1024, 0, 10);
lcd.print(currentPotValue);
delay(1000);
}