I am wondering how I can use a variable such as "count=1" to do multiple functions in my program in different loops.
`#include <LiquidCrystal.h>
// put your setup code here, to run once:
int count = 0;
int ButtonPin = 11;
int buttonState = 0;
int rs = 4;
int en = 9;
int d4 = 7;
int d5 = 6;
int d6 = 5;
int d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
pinMode(ButtonPin, INPUT_PULLUP); //when the push button is pressed, it will high on for aorund 20 seconds
}
void loop() {
lcd.setCursor(0, 0);
// put your main code here, to run repeatedly:
int value = analogRead(A0);
if (value < 200) {
count++;
}
buttonState = digitalRead(ButtonPin);
if (buttonState == HIGH) { `
while (count == 1) {
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Max Score: 5");
lcd.setCursor(4, 1);
lcd.print("Score: 1");
Serial.println("THIS IS ONEEEEEEEEEEEEE");
delay(10);
}
}
if (buttonState == LOW) { while (count == 1) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Thanks 4 playing");
delay(2000);
lcd.setCursor(1, 1);
lcd.print("Final Score: 1");
Serial.println("ONNNNNNNEEEEE");
delay(4000);
}
}
}
'