Need help for a way to select teams on my project

So I have a Cornhole scoreboard that I made. I have everything coded and working correctly. I had an idea of being able to choose the different teams names on the scoreboard. I have 5 buttons. 1 to reset the score, 1 to add points to team 1, 1 to subtract points from team 1, 1 to add points to team 2, and one to subtract points to team 2.

I was thinking that if I could have it so that when you hold down the reset button you could use the add and sub buttons to scroll through the teams. So you could set team 1 by using the add/sub for team 1 and then use the add/sub for team 2 to set the team 2 name.

I just don't know where to start and was looking for some ideas from people.

Let's start with the code you've written. Specifically, how are you capturing the input and can you add to that to accomplish the alternate menu option.

It seems like if you use the add and subtract buttons to scroll through the names you will not have a way to confirm both team names are set and it’s time for game on.

Here’s my proposal. Store all the team names in an array and have an index into the array for each team name. Have a boolean variable that determines if you are in name setting mode (as distinguished from scoring mode) which is set to true on a long reset press.

Use team 1 add button to scroll through the list of team names for team 1. When the end is reached it goes back to the first name on the list. Do the same for team 2 on the team 2 add button.

When both team names are set either subtract button will exit set name mode and the buttons will act as they do now.

I wrote some demo code that uses the serial monitor instead of buttons. Enter 1 for team 1 add, 2 for team 1 subtract, 3 for team 2 add and 4 for team 2 subtract.

You’ll see the team names printed in the serial monitor when entering 1 or 3 and the set team names when entering 2 or 4.

That’s my idea. Don’t know how difficult it would be to integrate into your code as I have not seen it.

// team names
const byte NUM_TEAMS = 3;
char *teamNames[] = {"badgers", "wombats", "lizards"};

// index into team names array
int team1 = (-1);
int team2 = (-1);

// setting name mode, set to true on long reset
bool setNameMode = false;


void setup() {
  Serial.begin(9600);

  // simulate long reset
  setNameMode = true;

}

void loop() {

  char inchar = '0';

  // simulate buttons on serial monitor
  // 1 = team 1 score add
  // 2 = team 1 score subtract
  // 3 = team 2 score add
  // 4 = team 2 score subtract
  //
  if ( Serial.available() > 0 )
  {

    inchar = Serial.read();

    // if in set name mode
    if ( setNameMode )
    {

      if ( inchar == '1' )
      {
        // team 1 score add button

        // increment team 1 index, wrap to first name
        if ( ++team1 == NUM_TEAMS ) team1 = 0;

        Serial.println(teamNames[team1]);

      } else if ( inchar == '3' ) {
        // team 2 score add button

        // increment team 2 index, wrap to first name
        if ( ++team2 == NUM_TEAMS ) team2 = 0;

        Serial.println(teamNames[team2]);

      } else if ( (inchar == '2') || (inchar == '4' ) ) {
        // team 1 or 2 subtract button

        // stay in set name mode unless both names set
        setNameMode = ((team1 < 0) || (team2 < 0));

        // print set names
        if ( team1 >= 0 )
        {
          Serial.print("Team 1 - ");
          Serial.println(teamNames[team1]);
        }

        if ( team2 >= 0 )
        {
          Serial.print("Team 2 - ");
          Serial.println(teamNames[team2]);

        } // if

      } // else

    } else {

      // not in set name mode ...
      Serial.println("score change");

    } // else

  } // if

}