this is the whole code. It's a bit of a mess because I'm experimenting
int x;
int SG = 20;
long AS = 20;
int y;
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("SG");
lcd.setCursor(9,0);
lcd.print("AS");
lcd.setCursor(0,1);
lcd.print("Key ?");
}
void loop() {
x = analogRead (0);
lcd.setCursor(10,1);
if (x < 60) { //rechts
++AS;
lcd.setCursor(12,0);
lcd.print(AS);
if (AS > 100) AS = 0;
delay(100);
}
else if (x < 200) {
lcd.print ("Up ");// stap vooruit
}
else if (x < 400){
lcd.print ("down");//stap achteruit
}
else if (x < 600){ // links
++SG;
lcd.setCursor(4,0);
lcd.print(SG);
delay(100);
}
else if (x < 800){
lcd.print ("start");//uitvoering AS * SG
}
}
if (x < 60) { //rechts
++AS; // AS is incremented (after a previous clear)
lcd.setCursor(12,0);
lcd.print(AS); // and then printed
if (AS > 100) AS = 0; // AS is cleared
// move the lcd.print to here instead
delay(100);
}
I think you're seeing residual characters on the LCD. When 100 is sent to the LCD, then AS gets reset to 0 (or 1), the next print only prints a single character (e.g. 1) and the two zeroes from the 100 remain.
Try something like
x = analogRead (0);
lcd.setCursor(10,1);
if (x < 60) { //rechts
++AS;
lcd.setCursor(12,0);
lcd.print(AS);
lcd.print(" ");
if (AS > 100) AS = 0;
delay(100);