I have used a switch case in my Arduino project and also I have used a for loop on my second case, but the function is not getting out of the for loop. I want to run my second case only for 5sec then wants to break it. Help me with that.
int cmd;
void loop(){ // run over and over again
if(Serial.available()){
Serial.println("enter 1 or 2");
cmd=Serial.read();
switch (cmd){
case '1':
function1() ;
break ;
case '2':
int i=0;
for(i=0;i<100;i++){
function2();
delay(50);
}
break;
}
}
}