how to pause for user input and continue the iteration of for loop

  arduino, arduino-ide, c++, loops

the for loop is not continuing after sending some thing via serial monitor
it stops at this is 0 but wont go to this is 1 , below is the simple code of what i’am trying to do


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {
  
    for(int j=0;j<=5;j++){
      
       while(!Serial.available()){
        
        Serial.println("this is "+String(j));
    }
    
   continue;
  }


}

it should print this is 0 wait for me to enter some thing via serial and continue to next iteration i.e this is 1 and again wait for me to allow it to iterate to next value . thanks for taking your time to help me

Source: Windows Questions C++

LEAVE A COMMENT