Hi, I show you the code and then I make my question…
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
int rpm = 0;
int rpmnw = 0;
int potpin = 0;
void setup () {
lcd.begin(16,2);
}
void loop () {
rpm = analogRead(potpin);
rpm = map(rpm,0,1023,65,200);
rpm *= 10;
if (rpm != rpmnw) {
rpmnw = rpm;
char buf[8];
sprintf(buf,"%4d RPM ",rpm);
lcd.write(buf);
}
delay(2000);
lcd.clear();
}
So I my code read the 10K potentiometer and map it to a desirable value then format it with sprintf and print it to lcd, but I want it to happens only when I make changes on the pot so I add an statement to the code to try to make it… but it doesn't work… it keeps displaying the value at the lcd and I don't know why…
Then my question is where is the mistake?