I have a program with a joystick and a LCD. The joystick controls "!"s on the LCD(makes them appear in different places. The joystick if made from potentiometers and when the value gets to a certain point a "!" is suppose to appear on a part of the screen using a while loop. When the value reaches the point to show a "!" on the screen the while loop starts and stops the anologue input from the potentiometers. This makes the value constant forever and the "!" never goes away. An IF statement hasn't worked because i need to clear the screen if the value is not correct for that "!" and that makes it impossible for other "!"s never appear. Are there any solutions to this or other ways of going about it? I am inexperienced so I am in much need of help. (BTW the code is made for four different potentiometers (Two joysticks) but I an only using one joystick (so two potentiometers, sensePinOrange with val1, and, sensePinYellow with val).) CODE:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensePinYellow =0;
int sensePinOrange =1;
int sensePinBrown =2;
int sensePinBlue =3;
int val = 0;
int val1 = 0;
int val2 = 0;
int val3 = 0;
void setup() {
analogReference(DEFAULT);
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
val = analogRead(sensePinYellow);
val1 = analogRead(sensePinOrange);
val2 = analogRead(sensePinBrown);
val3 = analogRead(sensePinBlue);
Serial. print(" Yellow=");
Serial. print(val); /*930=right 210=left */
Serial. print(" Orange=");
Serial. print(val1); //925=maxup 195=mindown
Serial. print(" Brown=");
Serial. print(val2); //930=right 180=left
Serial. print(" Blue=");
Serial. println(val3); //920=maxup 150=mindown
delay(50);
while (val > 700) {
lcd.setCursor(15,1); //right
lcd.print("!");
}
while (val < 400) {
lcd.setCursor(0,1); //left
lcd.print("!");
}
while (val1 > 700) {
lcd.setCursor(9,0); //up
lcd.print("!");
}
while (val < 400) {
lcd.setCursor(9,1); //down
lcd.print("!");
}
}