#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
String AnsEach = "";
String question[] = {"1.YongLong Bd?","2.Nes Age?","3.Louie Food?"
,"4.Cheer Color?","5.Pop girl type?"};
String answer1[] = {"a.18/10/49","b.12/11/49","c.26/06/49"};
String answer2[] = {"a.16","b.15","c.17"};
String answer3[] = {"a.Somtam","b.Kaiyang","c.KFC"};
String answer4[] = {"a.Pink","b.Blue","c.Yellow"};
String answer5[] = {"a.Japanese","b.China","c.All"};
int thetime = 1,count = 0;
byte score = 0;
bool showscore = false;
// bool inputname = false;
// String name = "";
void setup() {
Serial.begin(9600);
Serial.setTimeout(10);
lcd.init();
lcd.backlight();
intro();
}
void loop() {
if(count <= 4 ){
checkNext();
if(Serial.available() > 0){
AnsEach = Serial.readString();
AnsEach.trim();
Serial.print(AnsEach);
Serial.print("\nEnter your Answer :");
}
}
else{
if(showscore == false){
lcd.clear();
Showscore();
showscore = true;
}
}
}
void checkNext(){
if(thetime == 1){
if(AnsEach == "b"){
delay(1000);
lcd.clear();
count++;
thetime++;
score++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("currect");
Serial.print("Your Answer : currect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
if(count > 4){
lcd.clear();
}
}
else if(AnsEach == "a" || AnsEach == "c")
{
thetime++;
count++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("incurrect");
Serial.print("Your Answer : incurrect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
}
}
else if(thetime == 2)
{
if(AnsEach == "a"){
delay(1000);
lcd.clear();
count++;
thetime++;
score++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("currect");
Serial.print("Your Answer : currect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
if(count > 4){
lcd.clear();
}
}
else if(AnsEach == "b" || AnsEach == "c")
{
thetime++;
count++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("incurrect");
Serial.print("Your Answer : incurrect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
}
}
else if(thetime == 3)
{
if(AnsEach == "c"){
delay(1000);
lcd.clear();
count++;
thetime++;
score++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("currect");
Serial.print("Your Answer : currect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
if(count > 4){
lcd.clear();
}
}
else if(AnsEach == "a" || AnsEach == "b")
{
thetime++;
count++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("incurrect");
Serial.print("Your Answer : incurrect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
}
}
else if(thetime == 4)
{
if(AnsEach == "a"){
delay(1000);
lcd.clear();
count++;
thetime++;
score++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("currect");
Serial.print("Your Answer : currect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
if(count > 4){
lcd.clear();
}
}
else if(AnsEach == "b" || AnsEach == "c")
{
thetime++;
count++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("incurrect");
Serial.print("Your Answer : incurrect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
}
}
else if(thetime == 5)
{
if(AnsEach == "c"){
delay(1000);
lcd.clear();
count++;
thetime++;
score++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("currect");
Serial.print("Your Answer : currect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
if(count > 4){
lcd.clear();
}
}
else if(AnsEach == "a" || AnsEach == "b")
{
thetime++;
count++;
AnsEach = "";
lcd.clear();
lcd.setCursor(4,2);
lcd.print("incurrect");
Serial.print("Your Answer : incurrect\n");
Serial.print("Enter your Answer :");
delay(500);
lcd.clear();
showQ();
showA();
}
}
delay(1000);
showQ();
showA();
}
void showQ(){
lcd.setCursor(0, 0);
lcd.print(question[count]);
}
void showA()
{
if(thetime == 1)
{
lcd.setCursor(0, 1);
lcd.print(answer1[0]);
lcd.setCursor(0, 2);
lcd.print(answer1[1]);
lcd.setCursor(0, 3);
lcd.print(answer1[2]);
}
else if(thetime == 2)
{
lcd.setCursor(0, 1);
lcd.print(answer2[0]);
lcd.setCursor(0, 2);
lcd.print(answer2[1]);
lcd.setCursor(0, 3);
lcd.print(answer2[2]);
}
else if(thetime == 3)
{
lcd.setCursor(0, 1);
lcd.print(answer3[0]);
lcd.setCursor(0, 2);
lcd.print(answer3[1]);
lcd.setCursor(0, 3);
lcd.print(answer3[2]);
}
else if(thetime == 4)
{
lcd.setCursor(0, 1);
lcd.print(answer4[0]);
lcd.setCursor(0, 2);
lcd.print(answer4[1]);
lcd.setCursor(0, 3);
lcd.print(answer4[2]);
}
else if(thetime == 5)
{
lcd.setCursor(0, 1);
lcd.print(answer5[0]);
lcd.setCursor(0, 2);
lcd.print(answer5[1]);
lcd.setCursor(0, 3);
lcd.print(answer5[2]);
}
}
void Showscore(){
lcd.setCursor(0,1);
lcd.print("051, 055");
delay(500);
lcd.setCursor(0,2);
lcd.print("Your Score:");
lcd.setCursor(12,2);
lcd.print(score);
}
void intro(){
lcd.setCursor(0,0);
lcd.print("Q & A");
lcd.setCursor(0,1);
lcd.print("051, 055");
Serial.print("Enter your Answer :");
delay(4000);
lcd.clear();
}