while loop programming problem

Hi guys, could anyone tell me why the highlighted bit of code isnt working?

once i've stated some while loops i cant seem to get anything to work outside the while loops...?

void loop()
{
readShiftRegister();
if (shiftInputValue == 4)
{
delay(300);
lcd.clear();
options();
optionsCounter();
switch (counter2)
{
case 0:
lcd.setCursor(0,1);
lcd.write(Symbol_2);
lcd.setCursor(0,2);
lcd.write(Symbol_1);
lcd.setCursor(0,3);
lcd.write(Symbol_1);
break;
case 1:
lcd.setCursor(0,1);
lcd.write(Symbol_1);
lcd.setCursor(0,2);
lcd.write(Symbol_2);
lcd.setCursor(0,3);
lcd.write(Symbol_1);
break;
case 2:
lcd.setCursor(0,1);
lcd.write(Symbol_1);
lcd.setCursor(0,2);
lcd.write(Symbol_1);
lcd.setCursor(0,3);
lcd.write(Symbol_2);
break;
}
}

  while (counter <= 4)
  {
    symbolPositionCounter();
    switch(counter)
    {
      case 0:
        mainMenu();
        time();
        break;    
      case 1:
        lcd.setCursor(0,1);
        lcd.write(Symbol_2);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
            lcd.setCursor(0,3);
            lcd.write(Symbol_1);
              lcd.setCursor(10,1);
              lcd.write(Symbol_1);
              break;
      case 2:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_2);
            lcd.setCursor(0,3);
            lcd.write(Symbol_1);
              lcd.setCursor(10,1);
              lcd.write(Symbol_1);
              break;      
      case 3:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
            lcd.setCursor(0,3);
            lcd.write(Symbol_2);
              lcd.setCursor(10,1);
              lcd.write(Symbol_1);
              break;   
      case 4:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
            lcd.setCursor(0,3);
            lcd.write(Symbol_1);
              lcd.setCursor(10,1);
              lcd.write(Symbol_2);
              break;
    }
    {
      if (shiftInputValue == 16)
      {
        delay(300);
        lcd.clear();
        counter = 0;
      }
    }
    if (counter == 1 && shiftInputValue == 8)
    {
      delay(300);
      counter = 5;
      lcd.clear();
      pumpStatus("Pump One");
    }
    if (counter == 2 && shiftInputValue == 8)
    {
      delay(300);
      counter = 5;
      lcd.clear();
      pumpStatus("Pump Two");
    }
    if (counter == 4 && shiftInputValue == 8)
    {
      delay(300);
      counter = 5;
      lcd.clear();
      pumpStatus("Pump Three");
    }
    if (counter == 3 && shiftInputValue == 8)
    {
      delay(300);
      counter = 7;
      lcd.clear();
      setScheduleMenu();
    }
    if (counter == 5 && shiftInputValue !=8)
    {
      counter = 1;
    }
  }
  while ((counter == 5)||(counter == 6))
  {
    symbolPositionCounter();
    switch (counter)
    {
      case 5:
        lcd.setCursor(0,1);
        lcd.write(Symbol_2);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
          break;
      case 6:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_2);
          break;
    }
    if (shiftInputValue == 16)
    {
      delay(300);
      lcd.clear();
      counter = 0;
    }
    if ((counter == 5)||(counter == 7) && shiftInputValue !=8)
    {
      counter = 5;
    }
  }
  while (counter >= 7)
  {
    symbolPositionCounter();
    switch (counter)
    {
      case 7:
        lcd.setCursor(0,1);
        lcd.write(Symbol_2);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
            lcd.setCursor(0,3);
            lcd.write(Symbol_1);
            break;
      case 8:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_2);
            lcd.setCursor(0,3);
            lcd.write(Symbol_1);   
            break;
      case 9:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
            lcd.setCursor(0,3);
            lcd.write(Symbol_2);   
            break;
    }
    if (counter == 7 && shiftInputValue == 8)
    {
      delay(300);
      counter = 7;
      lcd.clear();
      adjustPump("Pump One");
    } 
    if (counter == 8 && shiftInputValue == 8)
    {
      delay(300);
      counter = 7;
      lcd.clear();
      adjustPump("Pump Two");
    }
    if (counter == 9 && shiftInputValue == 8)
    {
      delay(300);
      counter = 7;
      lcd.clear();
      adjustPump("Pump Three");
    } 
    if (shiftInputValue == 16)
    {
      delay(300);
      lcd.clear();
      counter = 0;
    }
    if ((counter == 10)||(counter == 6) && shiftInputValue !=8)
    {
      counter = 7;
    }
  }
}

You don't seem to have got the hang of what a while statement does, like you have not got the hang of posting code.

If a variable is used as a condition of the while statement there must be something inside that while loop that changes the variable otherwise you will loop round it forever.

oh i see. the programme is exiting the while loops as i can enter all three while loops.

you cant highlight bits of code in the coding box, that was why i did it like that, sorry

This code:-

while ((counter == 5)||(counter == 6))
  {
    symbolPositionCounter();
    switch (counter)
    {
      case 5:
        lcd.setCursor(0,1);
        lcd.write(Symbol_2);
          lcd.setCursor(0,2);
          lcd.write(Symbol_1);
          break;
      case 6:
        lcd.setCursor(0,1);
        lcd.write(Symbol_1);
          lcd.setCursor(0,2);
          lcd.write(Symbol_2);
          break;
    }
    if (shiftInputValue == 16)
    {
      delay(300);
      lcd.clear();
      counter = 0;
    }
    if ((counter == 5)||(counter == 7) && shiftInputValue !=8)
    {
      counter = 5;
    }
  }

Can never exit once it is started unless shiftInputValue == 16, any other state and it will loop forever.

You said:-

once i've stated some while loops i cant seem to get anything to work outside the while loops

That is because you are stuck in the while loop, you never get out and that is why the code you highlighted is not being performed, or as you see it not working.

thanks for the sarcasm, ive done it now tah :slight_smile: