1
if(menustate == 1310){menustate ++;Serial.println("Execution:");Serial.println(menustate);} 
 if(menustate == 1311){menustate ++;if (hr==0) menustate ++;else{aCount++;gpArray[aCount]=hr;}Serial.println("Execution GP:");Serial.println(menustate);}
 if(menustate == 1312){menustate ++;if (minu==0) menustate ++;else{aCount++;gpArray[aCount]=minu;}Serial.println("Execution GP:");Serial.println(menustate);}
 if(menustate == 1313){menustate ++;if (seco==0) menustate ++;else{aCount++;gpArray[aCount]=seco;}Serial.println("Execution GP:");Serial.println(menustate);}
 if(menustate == 1314){menustate ++;if (dates==0) menustate ++;else{aCount++;gpArray[aCount]=dates;}Serial.println("Execution GP:");Serial.println(menustate);}
 if(menustate == 1315){menustate ++;if (months==0) menustate ++;else{aCount++;gpArray[aCount]=years;}Serial.println("Execution GP:");Serial.println(menustate);}
 if(menustate == 1316){menustate ++;if (years==0) menustate ++;else{aCount++;gpArray[aCount]=years;}}
 if(menustate == 1320){menustate ++;}

I am trying to get different time inputs from users by using the menustate value , but here in this code the menustate starts from 1311 and without pressing anything the state goes directly to 1320 .and i cant get to the inbetween states

asked Mar 24, 2017 at 9:05

1 Answer 1

1

You should use a switch statement ... than after the switch statement you get the in between states:

// conditional loop
{
 // prepare for switch (if something is needed)
 switch (menustate)
 {
 case 1310:
 menustate ++;
 Serial.println("Execution:");Serial.println(menustate);
 break;
 case 1311:
 menustate ++;
 if (hr==0) 
 menustate ++;
 else
 { 
 aCount++;
 gpArray[aCount]=hr;
 }
 Serial.println("Execution GP:");Serial.println(menustate);
 break;
 case 1312:
 // ...
 default:
 // You can do here things with all other values
 }
 // Here you have the in between states available
}

You should put this switch statement in some conditional loop (like until an end state is reached.

SMFSW
3672 silver badges7 bronze badges
answered Mar 24, 2017 at 9:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.