I have create a trivia where the user must answer 5 questions by either pressing button A, B, or C. I can't figure out how to save the questions in my program. I tried using switch case, but it didnt work. For the sake of this project, the program is supposed to be simple. for now I only have two buttons (A and B).
What am I missing?
here is the code:
#include <stdio.h>
int startbuttonState = 0;
int buttonAstate = 0;
int buttonBstate=0;
int lastButtonState = 0;
int buttonPushCounter = 0;
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
Serial.begin(9600);
pinMode(13, OUTPUT);
Serial.println("Press start button to begin");
}
void loop() {
startbuttonState = digitalRead(2);
buttonAstate = digitalRead(3);
buttonBstate = digitalRead(4);
int questioncount=0;
if (startbuttonState==HIGH){
switch(questioncount) {
case 0:
Serial.println("What is a baby dog called?");
Serial.println("A)Puppy B)Kitten C)Cub D)Fawn");
delay (400);
if (buttonAstate=HIGH){
Serial.println("CORRECT");
questioncount=1;}
else if (buttonBstate==HIGH){
Serial.println("WRONG WRONG WRONG");
questioncount=0;}
delay(400);
break;
case 1:
Serial.println("What is a baby cat called?");
Serial.println("A)Puppy B)Kitten C)Cub D)Fawn");
delay (400);
if (buttonBstate=HIGH){
Serial.println("CORRECT");
questioncount=2;}
else if (buttonAstate==HIGH){
Serial.println("WRONG WRONG WRONG");
questioncount=0;}
delay(400);
break;
}
}
}