Go Down

Topic: Also to help with a case, then b, then select the option to return the case to  (Read 461 times) previous topic - next topic

tee1


       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.

Code: [Select]
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;


Code: [Select]
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;
         
     

}
}

UKHeliBob

Please explain the problem more clearly and post your complete program.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

econjack

Also, before you post your code, use Ctrl-T in the IDE. This will reformat your code to a more common C coding style and make it easier for us to read.

Go Up