Program stops outputting text on serial monitor after a certain point

Hi all,

I’m new to this form (and arduino/programming), so I apologize in advance for any stupid questions. I’m working on making an Orientation Box as a gift for my old boss.

One portion of this is a multiple choice exam with four buttons that stand for each of the answer options (A, B, C, D). I realized while doing this that the serial monitor stops outputting and the program stops checking answers after I make it print a certain amount of lines. I think this has to do with the Serial buffer but I’m really not sure and at a loss for how to fix it. Any advice/ideas would be greatly appreciated! My code is below.

int totalq_number = {
0, 1, 2, 3};
int qarray_size = 4;

int redState = 0;
int lastRed = 0;
int redPinA = 10;
int redbuttonPushCounter = 0;
int curr_redcounter = 0;

int blueState = 0;
int lastBlue = 0;
int bluePinB = 11;
int bluebuttonPushCounter = 0;
int curr_bluecounter = 0;

int greenState = 0;
int lastGreen = 0;
int greenPinC = 12;
int greenbuttonPushCounter = 0;
int curr_greencounter = 0;

int whiteState = 0;
int lastWhite = 0;
int whitePinD = 13;
int whitebuttonPushCounter = 0;
int curr_whitecounter = 0;

int answerCounter = 0;
int tryCounter = 0;
int prevAnsCounter = 0;

char *asking_order = {
"Question 1: ",
"Question 2: ",
"Question 3: ",
"Question 4: "
};

char *questions = {
“This is question 1- answer is A”,
“This is question 2- answer is B”,
“This is question 3- answer is C”,
“This is question 4- answer is D”
};

char *answers = {
“A. This is the red button 1”,
“B. This is the blue button 2”,
“C. This is the green button 3”,
“D. This is the white button 4”
};

char *option_a = {
“A. This is the red button 1”,
“A. This is the red button 2”,
“A. This is the red button 3”,
“A. This is the red button 4”
};

char *option_b = {
“B. This the blue button 1”,
“B. This is the blue button 2”,
“B. This is the blue button 3”,
“B. This is the blue button 4”
};

char *option_c = {
“C. This is the green button 1”,
“C. This is the green button 2”,
“C. This is the green button 3”,
“C. This is the green button 4”
};

char *option_d = {
“D. This is the white button 1”,
“D. This is the white button 2”,
“D. This is the white button 3”,
“D. This is the white button 4”
};

int i = 0;

void setup(){
Serial.begin(9600);
pinMode(redPinA, INPUT);
pinMode(bluePinB, INPUT);
pinMode(greenPinC, INPUT);
pinMode(whitePinD, INPUT);
delay(1000);
}

void loop(){
int val = totalq_number*;*

  • Serial.println("val= ");*

  • Serial.println(val);*

  • Serial.println(questions[val]);*

  • Serial.println(option_a[val]);*

  • Serial.println(option_b[val]);*

  • Serial.println(option_c[val]);*

  • Serial.println(option_d[val]);*

  • Serial.println("");*

  • Serial.println(“Adding another line of text 1”);*

  • Serial.println(“Adding another line of text 2”);*

  • Serial.println(“Adding another line of text 3”);*

  • Serial.println(“Adding another line of text 4”);*

  • Serial.println(“Adding another line of text 5”);*

  • Serial.println(“Adding another line of text 6”);*

  • Serial.println(“Adding another line of text 7”);*

  • Serial.println(“Adding another line of text 8”);*

  • Serial.println(“Adding another line of text 9”);*

  • Serial.println(“Adding another line of text 10”);*

  • Serial.println(“Adding another line of text 11”);*

  • Serial.println(“Adding another line of text 12”);*

  • Serial.println(“Adding another line of text 13”);*

  • Serial.println(“Adding another line of text 14”);*

  • Serial.println(“Adding another line of text 15”);*

  • Serial.println(“Adding another line of text 16”);*

  • Serial.println(“Adding another line of text 17”);*

  • Serial.println(“Adding another line of text 18”);*

  • Serial.println(“Adding another line of text 19”);*

  • Serial.println(“Adding another line of text 20”);*

// Serial.println(“Adding another line of text 21”);
// Serial.println(“Adding another line of text 22”);
// Serial.println(“Adding another line of text 23”);
// Serial.println(“Adding another line of text 24”);
// Serial.println(“Adding another line of text 25”);

// Serial.println(“Adding another line of text 26”);
// Serial.println(“Adding another line of text 27”);
// Serial.println(“Adding another line of text 28”);
// Serial.println(“Adding another line of text 29”);
// Serial.println(“Adding another line of text 30”);
*// *
// Serial.println(“Adding another line of text 31”);
// Serial.println(“Adding another line of text 32”);
// Serial.println(“Adding another line of text 33”);
// Serial.println(“Adding another line of text 34”);
// Serial.println(“Adding another line of text 35”);
// *
// Serial.println(“Adding another line of text 36”);
// Serial.println(“Adding another line of text 37”);
// Serial.println(“Adding another line of text 38”);
// Serial.println(“Adding another line of text 39”);
// Serial.println(“Adding another line of text 40”);
_ char
answer = answers[val];_

  • checkButton(answer, val);*
  • Serial.print("Answer = ");*
  • Serial.println(answer);*
  • Serial.print("Value = ");*
  • Serial.println(val);*
  • int addition = (redbuttonPushCounter) + (bluebuttonPushCounter) + (greenbuttonPushCounter) + (whitebuttonPushCounter);*
  • Serial.print("Sum of all pushes = ");*
  • Serial.println(addition);*
  • delay(1000);*
  • if (addition == 1){*
  • i++;*
  • addition = 0;*
  • redbuttonPushCounter = 0;*
  • curr_redcounter = 0;*
  • bluebuttonPushCounter = 0;*
  • curr_bluecounter = 0;*
  • greenbuttonPushCounter = 0;*
  • curr_greencounter = 0;*
  • whitebuttonPushCounter = 0;*
  • curr_whitecounter = 0;*
  • }*
  • if(i == 4){*
  • i = 0;*
  • }*
    }
    int checkButton(char* correct_answer, int value)
    {
  • while ((digitalRead(redPinA) == LOW) && (digitalRead(bluePinB) == LOW) && (digitalRead(greenPinC) == LOW) && (digitalRead(whitePinD) == LOW));*
  • Serial.println(“Passed button check”);*
  • redState = digitalRead(redPinA);*
  • blueState = digitalRead(bluePinB);*
  • greenState = digitalRead(greenPinC);*
  • whiteState = digitalRead(whitePinD);*
  • if (redState != lastRed){*
  • if (redState == HIGH){*
    char* sent_answer = option_a[value];
  • if (correct_answer == sent_answer){*
  • redbuttonPushCounter++;*
  • Serial.println(“Red button pressed”);*
  • Serial.print("Number of red pushes: ");*
  • Serial.println(redbuttonPushCounter);*
  • Serial.println(“CORRECT ANSWER SELECTED”);*
  • }*
  • else{*
  • Serial.println(“INCORRECT ANSWER- PLEASE TRY AGAIN”);*
  • }*
  • }*
  • // delay(1000);*
  • else{*
  • Serial.println(“Red not pressed”);*
  • }*
  • lastRed = redState;*
  • }*
  • // blueState = digitalRead(bluePinB);*
  • if (blueState != lastBlue){*
  • if (blueState == HIGH){*
    char* sent_answer = option_b[value];
  • if(correct_answer == sent_answer){*
  • bluebuttonPushCounter++;*
  • Serial.println(“Blue button pressed”);*
  • Serial.print("Number of blue pushes: ");*
  • Serial.println(bluebuttonPushCounter);*
  • // delay(1000);*
  • Serial.println(“CORRECT ANSWER SELECTED”);*
  • }*
  • else{*
  • Serial.println(“INCORRECT ANSWER- PLEASE TRY AGAIN”);*
  • }*
  • }*
  • else{*
  • Serial.println(“Blue not pressed”);*
  • }*
  • lastBlue = blueState;*
  • }*
  • // greenState = digitalRead(greenPinC);*
  • if (greenState != lastGreen){*
  • if (greenState == HIGH){*
    char* sent_answer = option_c[value];
  • if (correct_answer == sent_answer){*
  • greenbuttonPushCounter++;*
  • Serial.println(“Green button pressed”);*
  • Serial.print("Number of green pushes: ");*
  • Serial.println(greenbuttonPushCounter);*
  • Serial.println(“CORRECT ANSWER SELECTED”);*
  • // delay(1000);*
  • }*
  • else{*
  • Serial.println(“INCORRECT ANSWER- PLEASE TRY AGAIN”);*
  • }*
  • }*
  • else{*
  • Serial.println(“Green not pressed”);*
  • }*
  • lastGreen = greenState;*
  • }*
  • // whiteState = digitalRead(whitePinD);*
  • if (whiteState != lastWhite){*
  • if (whiteState == HIGH){*
    char* sent_answer = option_d[value];
  • if (correct_answer == sent_answer){*
  • whitebuttonPushCounter++;*
  • Serial.println(“White button pressed”);*
  • Serial.print("Number of white pushes: ");*
  • Serial.println(whitebuttonPushCounter);*
  • Serial.println(“CORRECT ANSWER SELECTED”);*
  • // delay(1000);*
  • }*
  • else{*
  • Serial.println(“INCORRECT ANSWER- PLEASE TRY AGAIN”);*
  • }*
  • }*
  • else{*
  • Serial.println(“White not pressed”);*
  • }*
  • lastWhite = whiteState;*
  • }*
  • return redbuttonPushCounter;*
  • return bluebuttonPushCounter;*
  • return greenbuttonPushCounter;*
  • return whitebuttonPushCounter;*
    }
    Thank you for everything!
    -Greenbean

Please read the posting guidelines relating to the use of code tags, and consider the amount of RAM you're using all those strings