When I work, it's usually a case of the loop until the first press made o k = 0, then press the b button and then looping normal functionality similar case a.
But when I returned to press a case, it loops back to the first round, I'm just one more part in the program.
void loop(){
if (Serial.available() > 0) {
inByte = Serial.read();
switch (inByte) {
case 'a':
while(k){
loop1();
check1();}
break;
case 'b':
grid();
while(l){
loop2();
check2();}
break;
void check1(){
if( ch== 'o'){
k=0;
l=1;
}
}
void check2(){
if (Serial.available() > 0) {
char ch2 = Serial.read();
if( ch2== 'o'){
l=0;
k=1;
}
}