Saving a switch input to choose mode of operation

consider following which simulates some of your routines


char
Numberpad ()  {
    if (Serial.available ())  {
        return Serial.read();
    }

    return 0;
}

void ModeStreet ()  { Serial.println (__func__);  };
void ModeAvenue ()  { Serial.println (__func__);  };
void ModeNight  ()  { Serial.println (__func__);  };

// -----------------------------------------------------------------------------
char mode;

void loop()
{
    char choice = Numberpad();
    Serial.println(choice);

    if ('A' == choice || 'B' == choice || 'C' == choice)
        mode = choice;

    switch (mode)  {
    case 'A':
        ModeStreet();
        break;

    case 'B':
        ModeAvenue();
        break;
    case 'C':
        ModeNight();
        break;
    }
}

void setup ()
{
    Serial.begin (9600);
}
1 Like