Hi all im having a problem where the while loop is interfering with the void loop by I have to answer all of the questions first then the void loop will work once I have all of the questions answered, I am making a true or false game and I want to change the questions using the serial monitor instead of the code, keep in mind that im still writing the code so thats why theres not lots of code. Heres the code
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
const int redled=13;
const int blueled=12;
const int greenled=11;
const int falsebutton=10;
const int truebutton=9;
const int buzzer=8;
String message1, message2, message3, message4, message5, message6, message7, message8, message9, message10;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(blueled, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(falsebutton, INPUT_PULLUP);
pinMode(truebutton, INPUT_PULLUP);
digitalWrite(blueled, HIGH);
messages();
}
void messages(){
Serial.println("Enter Question 1");
while(Serial.available()==0){}
message1=Serial.readString();
Serial.println("Enter Question 2");
while(Serial.available()==0){}
message2=Serial.readString();
Serial.println("Enter Question 3");
while(Serial.available()==0){}
message3=Serial.readString();
Serial.println("Enter Question 4");
while(Serial.available()==0){}
message4=Serial.readString();
Serial.println("Enter Question 5");
while(Serial.available()==0){}
message5=Serial.readString();
Serial.println("Enter Question 6");
while(Serial.available()==0){}
message6=Serial.readString();
Serial.println("Enter Question 7");
while(Serial.available()==0){}
message7=Serial.readString();
Serial.println("Enter Question 8");
while(Serial.available()==0){}
message8=Serial.readString();
Serial.println("Enter Question 9");
while(Serial.available()==0){}
message9=Serial.readString();
Serial.println("Enter Question 10");
while(Serial.available()==0){}
message10=Serial.readString();
Serial.println("You have finished all of the questions");
}
void loop(){
lcd.setCursor(0, 0); //Just testing to see the loop works here.
lcd.print(message1);