While loop exit condition

i have function like this. How to exit from while loop condition here.

button = read_LCD_buttons();
    while(button!=btnSELECT)
    {
     DS_Counter=Display_selection();
     switch(DS_Counter)
     {
      case 1:  lcd.setCursor(0,0); digitalClockDisplay();timedBeep(shortBeep,1);  break;
      case 2: lcd.setCursor(0,0);Display_angle();timedBeep(shortBeep,1); break;
      case 3: lcd.setCursor(0,0);Display_coordinate();timedBeep(shortBeep,1);break;
      case 4:lcd.setCursor(0,0);Display_Wind();timedBeep(shortBeep,1);break;
      case 5:break;                     
      }
    		
    }
    int Display_selection()
    {
     int button = read_LCD_buttons();
     if(button==btnUP)
       Display_counter++;
     if(button==btnDOWN)
       Display_counter--;
     if(Display_counter>5)
     {
       Display_counter=0;
     }
     return(Display_counter);  
    }

You need to read the button again, this time in the while loop.

The while loop has only one condition

while(button!=btnSELECT)

It will exit when

button == btnSELECT

but in order for it to exit you must update either button or btnSELECT must be updated within the while or by an interrupt.

I tried this way here also not exiting

 while(button!=btnSELECT)
       {
              
        DS_Counter=Display_selection();
          switch(DS_Counter)
            {
              case 1:  lcd.setCursor(0,0); digitalClockDisplay();timedBeep(shortBeep,1);  break;
              case 2: lcd.setCursor(0,0);Display_angle();timedBeep(shortBeep,1); break;
              case 3: lcd.setCursor(0,0);Display_coordinate();timedBeep(shortBeep,1);break;
             case 4:lcd.setCursor(0,0);Display_Wind();timedBeep(shortBeep,1);break;
             case 5: break;
            
             }
            
                              
            }
        button = read_LCD_buttons();
             if(button==btnSELECT)
             {
               break;
             }
            
         }

Check your brackets, your not reading the button in the while loop.

HazardsMind:
Check your brackets, your not reading the button in the while loop.

I put condition and checked it not going out of loop.

You put your button read and test outside of the loop, but it needs to be inside your loop.

void lcd_call()
{
 int button = 0; 
 menuOption = 1;

lcdClear();
lcd.print("MENU DISPLAY:");
menuOption = 1;
while (menuOption <= menuOptions)
  {
    menuOption = 1;
     button = read_LCD_buttons();
     if (button == btnRIGHT)
    {
      timedBeep(longBeep,1);   
      menuOption++;
       if (menuOption == 2)
      {
        lcdClear();
        lcd.print("DISPLAY:");  
      //  button = read_LCD_buttons();
        while(button!=btnSELECT)
          {
            
           DS_Counter=Display_selection();
          switch(DS_Counter)
            {
              case 1:  lcd.setCursor(0,0); digitalClockDisplay();timedBeep(shortBeep,1);  break;
              case 2: lcd.setCursor(0,0);Display_angle();timedBeep(shortBeep,1); break;
              case 3: lcd.setCursor(0,0);Display_coordinate();timedBeep(shortBeep,1);break;
             case 4:lcd.setCursor(0,0);Display_Wind();timedBeep(shortBeep,1);break;
             case 5: break;   
             }
              button = read_LCD_buttons();  
            if(button==btnSELECT)
              {
                break;
              }
                              
           }
           if(button==btnSELECT)
              {
                break;
              }   
        
            
       }
      
      
       if (menuOption == 3)
      {
         //lcd.setCursor(0,0);
        lcdClear();
        lcd.print("SET PARAMETER");  
delay(1000);        
      }
    }


	 if((button == btnUP))
    {
      lcdClear();
      lcd.print("welcome");
      menuOption=1;
    }
    
  }
    
  }

The IDE has an auto format tool.
Please use it before you post any more code.
My eyes hurt.

AWOL:
The IDE has an auto format tool.
Please use it before you post any more code.
My eyes hurt.

void lcd_call()
{
  int button = 0; 
  menuOption = 1;
  lcdClear();
  lcd.print("MENU DISPLAY:");

  while (menuOption <= menuOptions)
  {

    button = read_LCD_buttons();
    if (button == btnRIGHT)
    {
      //timedBeep(shortBeep,1);   
      menuOption++;
      if (menuOption == 2)
      {
        lcdClear();
        lcd.print("DISPLAY:");  
        button = read_LCD_buttons();


        while((button = read_LCD_buttons()) != btnLEFT)
        {
          Serial.println(button);
          DS_Counter=Display_selection();
          switch(DS_Counter)
          {
          case 1:  
            lcd.setCursor(0,0); 
            digitalClockDisplay();
            timedBeep(shortBeep,1);  
            break;
          case 2: 
            lcd.setCursor(0,0);
            Display_angle();
            timedBeep(shortBeep,1); 
            break;
          case 3: 
            lcd.setCursor(0,0);
            Display_coordinate();
            timedBeep(shortBeep,1);
            break;
          case 4:
            lcd.setCursor(0,0);
            Display_Wind();
            timedBeep(shortBeep,1);
            break;
          case 5: 
            break;   
          }
          Serial.println(button);                          
        }

        menuOption++;


      }
      if (menuOption == 3)
      {
        lcdClear();
        lcd.print("SET PARAMETER");
        int button1 = read_LCD_buttons();
        while((button1 = read_LCD_buttons()) != btnLEFT)
        {
          Serial.println(button1);
          Set_Counter=Display_selection();
          switch(Set_Counter)
          {
          case 1:  
            lcd.setCursor(0,0); 
            setDateTime();
            timedBeep(shortBeep,1);  
            break;
          case 2: 
            lcd.setCursor(0,0);
            set_latitude();
            timedBeep(shortBeep,1); 
            break;
          case 3: 
            lcd.setCursor(0,0);
            set_longitude() ;
            timedBeep(shortBeep,1);
            break;
          case 4:
            lcd.setCursor(0,0);
            set_trackertime();
            timedBeep(shortBeep,1);
            break;
          case 5: 
            break;   
          }
          Serial.println(button1);                          
        }
        // menuOption++;
      }
      if(menuOption == 4)
      {
        lcdClear();
        lcd.print("EXIT WINDOW");
      }   
    }
  }



}
        while((button = read_LCD_buttons()) != btnLEFT)

Did you mean to put 2 statements in the while condition like that ? What condition(s) are you testing for exactly ?
In my opinion it is much clearer to read the button state in one statement and then test its value in a second statement.

UKHeliBob:

        while((button = read_LCD_buttons()) != btnLEFT)

Did you mean to put 2 statements in the while condition like that ? What condition(s) are you testing for exactly ?
In my opinion it is much clearer to read the button state in one statement and then test its value in a second statement.

Initially i tried with (button !=btnLEFT) it didn't worked, but above statement worked for me. Now I am facing problem entering into Setperameter window and changing option in same code

Your code may work but to me this would be clearer

while(button != btnLEFT)
{
  button = read_LCD_buttons();

  //code to be executed while the left button is not pressed goes here 
}
//code to be executed when left button is pressed goes here

The question Here is In while loop how to check condition so that it comes out of loop, so i changed the function .If button is not equal to left i.e true SO it executing switch cases. suppose i pressed left key it has to go out of loop AND execute .out loop functions. But in my code initially it not executing.

while(button != btnLEFT)
{
  button = read_LCD_buttons();
..........Switch cases:............
  //code to be executed while the left button is not pressed goes here 
}
..........out loop functions.................

Now in Same code i am facing problem on changing Menu selection before entering Display function if press right key it is not going to Set parameter function:
Every time i need to Enter in to Display function and goes to set parameter , What is wrong i am doing

Updated Code running. with Display section working fine , but could not able to enter the Set perameter menu from Begining. Every time i need to enter the display parameter and then enter into set parameter function .

void lcd_call()
{
  int button = 0; 
  menuOption = 1;
  lcdClear();
  lcd.print("MENU DISPLAY:");

  while (menuOption <= menuOptions)
  {

    button = read_LCD_buttons();
    if (button == btnRIGHT)
    {
      //timedBeep(shortBeep,1);   
      menuOption++;
      if (menuOption == 2)
      {
        lcdClear();
        lcd.print("DISPLAY:");  
        button = read_LCD_buttons();


        while((button = read_LCD_buttons()) != btnLEFT)
        {
          Serial.println(button);
          DS_Counter=Display_selection();
          switch(DS_Counter)
          {
          case 1:  
            lcd.setCursor(0,0); 
            digitalClockDisplay();
            timedBeep(shortBeep,1);  
            break;
          case 2: 
            lcd.setCursor(0,0);
            Display_angle();
            timedBeep(shortBeep,1); 
            break;
          case 3: 
            lcd.setCursor(0,0);
            Display_coordinate();
            timedBeep(shortBeep,1);
            break;
          case 4:
            lcd.setCursor(0,0);
            Display_Wind();
            timedBeep(shortBeep,1);
            break;
          case 5: 
            break;   
          }
          Serial.println(button);                          
        }

        menuOption++;


      }
      if (menuOption == 3)
      {
        int button1;
        lcdClear();
        lcd.print("SET PARAMETER");
        button1 = read_LCD_buttons();
        while(Set_Counter<5)
        {
          Serial.println(button1);
          Set_Counter=Select_section();

          switch(Set_Counter)
          {
          case 1:           
            if(button1 ==btnRIGHT)
            {
              Set_Counter++; 
              //Set_flag=1; 
            }
            else
            {
              lcd.setCursor(0,0); 
              setDateTime();
              timedBeep(shortBeep,1);
              button1 = read_LCD_buttons();
            }
            break;
          case 2: 
            lcd.setCursor(0,0);
            set_latitude();
            timedBeep(shortBeep,1); 




          case 3: 
            lcd.setCursor(0,0);
            set_longitude() ;
            timedBeep(shortBeep,1);
            Set_Counter+1; 
            break;
          case 4:
            lcd.setCursor(0,0);
            set_trackertime();
            timedBeep(shortBeep,1);
            Set_Counter+1; 
            break;
          case 5: 
            break;   
          }
          Serial.println(button1); 
          Set_Counter=Select_section();  
          //Set_flag=0;        
        }
        // menuOption++;
      }
      if(menuOption == 4)
      {
        lcdClear();
        lcd.print("EXIT WINDOW");
      }   
    }
  }



}

Time to post the whole of your current code then.

UKHeliBob:
Time to post the whole of your current code then.

Code is Here , Where i am putting all together

void lcd_call()
{
  int button = 0; 
  menuOption = 1;
  lcdClear();
  lcd.print("MENU DISPLAY:");

  while (menuOption <= menuOptions)
  {

    button = read_LCD_buttons();
    if (button == btnRIGHT)
    {
      //timedBeep(shortBeep,1);   
      menuOption++;
      if (menuOption == 2)
      {
        lcdClear();
        lcd.print("DISPLAY:");  
        button = read_LCD_buttons();


        while((button = read_LCD_buttons()) != btnLEFT)
        {
          Serial.println(button);
          DS_Counter=Display_selection();
          switch(DS_Counter)
          {
          case 1:  
            lcd.setCursor(0,0); 
            digitalClockDisplay();
            timedBeep(shortBeep,1);  
            break;
          case 2: 
            lcd.setCursor(0,0);
            Display_angle();
            timedBeep(shortBeep,1); 
            break;
          case 3: 
            lcd.setCursor(0,0);
            Display_coordinate();
            timedBeep(shortBeep,1);
            break;
          case 4:
            lcd.setCursor(0,0);
            Display_Wind();
            timedBeep(shortBeep,1);
            break;
          case 5: 
            break;   
          }
          Serial.println(button);                          
        }

        menuOption++;


      }
      if (menuOption == 3)
      {
        int button1;
        lcdClear();
        lcd.print("SET PARAMETER");
        button1 = read_LCD_buttons();
        while(Set_Counter<5)
        {
          Serial.println(button1);
          Set_Counter=Select_section();

          switch(Set_Counter)
          {
          case 1:           
            if(button1 ==btnRIGHT)
            {
              Set_Counter++; 
              //Set_flag=1; 
            }
            else
            {
              lcd.setCursor(0,0); 
              setDateTime();
              timedBeep(shortBeep,1);
              button1 = read_LCD_buttons();
            }
            break;
          case 2: 
            lcd.setCursor(0,0);
            set_latitude();
            timedBeep(shortBeep,1); 




          case 3: 
            lcd.setCursor(0,0);
            set_longitude() ;
            timedBeep(shortBeep,1);
            Set_Counter+1; 
            break;
          case 4:
            lcd.setCursor(0,0);
            set_trackertime();
            timedBeep(shortBeep,1);
            Set_Counter+1; 
            break;
          case 5: 
            break;   
          }
          Serial.println(button1); 
          Set_Counter=Select_section();  
          //Set_flag=0;        
        }
        // menuOption++;
      }
      if(menuOption == 4)
      {
        lcdClear();
        lcd.print("EXIT WINDOW");
      }   
    }
  }
}

_1.rar (3.72 KB)

After going to the trouble of downloading and extracting your code (why not just attach the files ?) what do I find ?
The code does not even compile !
What is this all about ?

          case 2: 
            lcd.setCursor(0,0);
            set_latitude();
            timedBeep(shortBeep,1); 
            goto longi;

Not only do you have a (Yuk) goto in the program, the label that it tries to jump to does not even exist.

i could not able to change menu:
In order to go from Display to set_parameter i need to enter display parameter first and then enter to the Set parameter.
When I enter into Set parameter some time directly goes to longitude.or remain in same thing even longitude is SET

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define btnRIGHT  0		// Okay
#define btnUP     1		// inc
#define btnDOWN   2		// dec
#define btnLEFT   3		// Select
#define btnSELECT 4		// Menu
#define btnNONE   5
#define beeper A1      // Alarm buzzer
#define shortBeep 100
#define longBeep  500

void setup()
{
	Serial.begin(9600);
}
void loop()
{
	LCD_MENU();
}
void LCD_MENU()
{

int button = 0; 
  menuOption = 1;
  lcdClear();
  lcd.print("MENU DISPLAY:");

  while (menuOption <= menuOptions)
  {

    button = read_LCD_buttons();
    if (button == btnRIGHT)
    {
      timedBeep(shortBeep,1);   
      menuOption++;
  }else
  {
    menuOption;
  }
switch(menuOption)
      {
      case 2:  lcdClear();lcd.print("DISPLAY:");
        while((button = read_LCD_buttons()) != btnLEFT)
        {
          Serial.println(button);
          DS_Counter=Display_selection();
          switch(DS_Counter)
          {
          case 1:lcd.setCursor(0,0);digitalClockDisplay(); timedBeep(shortBeep,1); break; 
          case 2: lcd.setCursor(0,0);Display_angle(); timedBeep(shortBeep,1); break; 
          case 3:lcd.setCursor(0,0);Display_coordinate(); timedBeep(shortBeep,1); break;
          case 4:lcd.setCursor(0,0); Display_Wind(); timedBeep(shortBeep,1);break;
           case 5: break;    
          }
          button = read_LCD_buttons();
          //menuOption++;                        
        }

      case 3:
        lcdClear();
        lcd.print("SET PARAMETER");
		while(Set_Counter<5)
        {          
          Set_Counter=Select_section();
		   switch(Set_Counter)
          {
		   case 1:setDateTime();timedBeep(shortBeep,1);break;
           case 2:set_latitude();timedBeep(shortBeep,1);break;
           case 3:set_longitude() ; timedBeep(shortBeep,1);break;
           case 4:set_trackertime();timedBeep(shortBeep,1);break;
           case 5:break;             
          }

          Set_Counter=Select_section();  
          menuOption++;     
        }
        break;

      case 4:
        lcd.begin(16,2);
        lcd.setCursor(0,0);
        lcd.print("EXIT WINDOW");
        break; 


      }
    }





}
int read_LCD_buttons()
{
  adc_key_in = analogRead(0);      // read the value from the sensor
  // my buttons when read are centered at these valies: 0, 131, 307, 481, 722
  // we add approx 50 to those values and check to see if we are close
  // No button pressed should be 1023
  if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
  if (adc_key_in < 50)   return btnRIGHT; 
  if (adc_key_in < 195)  return btnUP;
  if (adc_key_in < 380)  return btnDOWN;
  if (adc_key_in < 555)  return btnLEFT;
  if (adc_key_in < 790)  return btnSELECT;  
  // return btnNONE;  // when all others fail, return this...

}
void digitalClockDisplay()
{
	lcd.print("date");

}
void Display_angle()
{
	lcd.print("angle:");
	lcd.print(45.0)
}
void Display_coordinate()
{
	lcd.print("coordinate");
	lcd.print(13.04);
}
void Display_Wind()
{
	lcd.print("wind speed");
	lcd.print(30.0);
}

float set_latitude()
{


  float lastlatitude_degree=latitude;

  //lastlatitude_degree=latitude;

  if (lastlatitude_degree>0.0 && lastlatitude_degree<99.00)
  {
    latitude=Get_Degree_set("Latitude_degree", lastlatitude_degree, 99.00);
    timedBeep(shortBeep,5);
  }
  else
  {
    timerCancelled("");     
  }  


  Serial.print("Latitude set:");
  Serial.print(latitude);
  return(latitude);
}   

float Get_Degree_set(char timerText[], float startNum, float  maxCount)
{

  float  Degree = startNum;
  int button = 0;
  lcdClear();
  lcd.print(timerText);
  lcd.setCursor(0,1);
  lcd.print(Degree);   

  while (button != btnSELECT)
  {
    button = read_LCD_buttons();

    if(button==btnUP)
    {
      timedBeep(shortBeep,3);
      Degree=Degree+0.2;
    }
    else
      if(button==btnDOWN)
      {
        timedBeep(shortBeep,3); 
        Degree=Degree-0.2;
      }  

    if (button == btnRIGHT)
    {
      timedBeep(shortBeep,1);
      return Degree; 
    }
    lcd.setCursor(0,1);
    lcd.print(Degree); 
    lcd.print("   ");
  }

  return 0;



}
float set_longitude()
{
  float lastlongitude_deg=60.0;
  //lastlongitude_deg= longitude;
  if (lastlongitude_deg>0.00 && lastlongitude_deg<99.00)
  {
    longitude=Get_Degree_set("Longitude_degree:", lastlongitude_deg,99.00);
    timedBeep(shortBeep,20);

  }
  else
  {
    timerCancelled("");     
  } 
  Serial.print("Longitude set:");
  Serial.print(longitude);    
  return(longitude);

}

void setDateTime()
 {
 // int button = 0;
 lcdClear();
 lcd.print("DATE-TIME");
 //get month
 mm = getTimerMinutes("Set Month", lastMonth, 12);
 if (mm > 0 && mm < 13)
 {
 //get day
 // default day and hour settings on set date/time
 dd = getTimerMinutes("Set Day", lastDay, 31);
 if (dd > 0 && dd < 32)
 {
 //get year
 yy = getTimerMinutes("Set Year", lastYear, 2999);
 if (yy > 2000 && yy < 3000)
 {
 //get hour
 int thisHour = lastHour;
 // default day and hour settings on set date/time
 h = getTimerMinutes("Set Hour", thisHour, 23);
 if (h >= 0 && h < 24)
 {
 //get minutes
 m = getTimerMinutes("Set Minute", lastMinute, 59);
 if (m < 60)
 {
 // RTC.adjust(DateTime(setYear,setMonth,setDay,setHour,setMinute)); // for DS1307
 //setTime(setHour, setMinute, 0, setDay, setMonth, setYear); // sec, min, hour, date, month, year
 // rtcSetup();
 //rtcWrite();
 
 lcd.setCursor(0,0);
 lcd.print("Saving...     ");
 delay(1000);
 
 return;       
 }
 else
 {
 timerCancelled("");
 return;  
 }  
 }
 else
 {
 timerCancelled("");     
 }    
 }     
 else
 {
 timerCancelled("");       
 }
 }
 else
 {
 timerCancelled("");     
 }    
 }     
 else
 {
 timerCancelled("");       
 }
 
 }

int getTimerMinutes(char timerText[], int startNum, int maxCount)
{
  int minutes = startNum;
  int button = 0;
  lcdClear();
  lcd.print(timerText);
  lcd.setCursor(0,1);
  lcd.print(minutes);   

  while (button != btnSELECT)
  {
    button = read_LCD_buttons();
    //Serial.println(button);

    if (button == btnLEFT)
    {
      if ((minutes + 10) <= maxCount)
      {
        timedBeep(shortBeep,1);
        minutes = minutes + 10;
      }
      else
      {
        timedBeep(shortBeep,2); 
      }
    }

    if (button == btnUP)
    {
      if (minutes < maxCount)
      {
        timedBeep(shortBeep,1);
        minutes++;
      }
      else
      {
        timedBeep(shortBeep,2);
        minutes = 0;
      }
    }
    if (button == btnDOWN)
    {
      if (minutes > 0)
      {
        timedBeep(shortBeep,1);
        minutes--;
      }
      else
      {
        timedBeep(shortBeep,2); 
        minutes = maxCount;
      }   
    } 
    if (button == btnRIGHT)
    {
      timedBeep(shortBeep,1);
      return minutes; 
    }
    lcd.setCursor(0,1);
    lcd.print(minutes); 
    lcd.print("   ");
  }
  return 0;
}

That code does not compile making it difficult/impossible to help.