While loop inside a switch case

Good morning,

can we add a while loop inside a switch case

case 'C':
  {
    
    while (j<=3)
    {  Serial.println("j=");Serial.print(j);
      for(int i=0;i<16;i++)
      { 
        if((abs(value -A[i])<2))
        {
          Serial.println(Keypad[i]);
          Serial.println("j=");Serial.print(j);
          pass[j] = Keypad[i];
          j=j+1; 
          while(analogRead(A0)<1000) {delay(100);}
          W_data_8bit(Keypad[i]);
        }
      }
    }
    var = '0'; 
    break;
  }

The program exist the code, despite that j is still less than 3

How do you know the program existed? Does it continue execute code or it just stops printing?

It goes back to reading and displaying sensor value that is not in the switch

FutureEngineer:
It goes back to reading and displaying sensor value that is not in the switch

can you post the outputs?

What is the value of j when the 'C' case code is entered ?
How and where is it declared ?

Print it before the while loop. Is its value what you expect ?

Case for [Snippets R Us :wink:

And tip, press Ctrl+T, look a lot better, right?](http://snippets-r-us.com/)