3 button Menu Program.....will not update sensor input


i've been trying adapt menu system project , first menu "menu1" contains sensor readings 1,2 , 3.
these sensor readings need update every time loop repeats.  code works great until insert sensor code menu function, when push enter button "menu1" sensor readings update  not continue update.  way can them update pushing enter button every second.  assume because sensor code being called when "enterbutton" pressed bringing input high split second , loop updates when "enterbutton" pressed.  there way sensor code loop in "menu" function.  please have @ code below.

code: [select]
void loop()
      {
         
         input = analogread(a0);
         mypid.compute();
        /************************************************
         * turn output pin on/off based on pid output
         ************************************************/
        if(millis() - windowstarttime>windowsize)
        { //time shift relay window
        windowstarttime += windowsize;}
        if(output < millis() - windowstarttime) digitalwrite(relaypin,high);
        else digitalwrite(relaypin,low);
       
             
         btndownstate = digitalread(btndownpin);
         btnenterstate = digitalread(btnenterpin);
           
          //the down button
        if (btndownstate != btndownlaststate)
           {
             if (btndownstate == high && newstate == 0)
               {
           
                  if (btndowncounter < 4)
                    {btndowncounter++;}
                     
                      else
                        {btndowncounter = 1;}
                 
             
                  if (btndowncounter == 1) {         //menu 1
                    lcd.clear();
                    lcd.setcursor(0, 0);
                    lcd.print(">menu1");
                    lcd.setcursor(0, 1);
                    lcd.print("menu2");
                  } else if (btndowncounter == 2) {  //menu 2
                    lcd.clear();
                    lcd.setcursor(0, 0);
                    lcd.print(">menu2");
                    lcd.setcursor(0, 1);
                    lcd.print("menu3");
                  } else if (btndowncounter == 3) {  //menu 3
                    lcd.clear();
                    lcd.setcursor(0, 0);
                    lcd.print(">menu3");
                    lcd.setcursor(0, 1);
                    lcd.print("menu4");
                  } else if (btndowncounter == 4) {  //menu 4
                    lcd.clear();
                    lcd.setcursor(0, 0);
                    lcd.print(">menu4");
                    lcd.setcursor(0, 1);
                    lcd.print("menu1");
                  }
           
              }
           
          }
                     
            btndownlaststate = btndownstate;
           
            //the enter button
            if (btnenterstate == high)
          {
              if (btndowncounter == 1)
                 {
                  lcd.clear();
                  lcd.setcursor(0, 0); // set cursor column 0, line 0
                  lcd.print("ppo1");  // print message lcd.
   
                  lcd.setcursor(6, 0); // set cursor column 6, line 0
                  lcd.print("ppo2"); // print message lcd
   
                  lcd.setcursor(12, 0); // set cursor column 12, line 0
                  lcd.print("ppo3");  // print message lcd.
               
                  lcd.setcursor(0, 1); //sets cursor column 0, line 1   
                  inputreading1 = analogread(sensor1); //getting voltage reading 02 sensor   
                  float voltage1 = inputreading1 * aref_voltage; // converting reading voltage
                  voltage1 /= 1024.0;   
                  lcd.print(voltage1, 2);//print actual voltage lcd   
                  delay(200);
           
       
                  lcd.setcursor(6, 1); //sets cursor column 6, line 1     
                  inputreading2 = analogread(sensor2); //getting voltage reading temperature sensor   
                  float voltage2 = inputreading2 * aref_voltage; // converting reading voltage
                  voltage2 /= 1024.0;
                  lcd.print(voltage2, 2);  //print actual voltage lcd
                  delay(200);     
         
         
                  lcd.setcursor(12, 1); //sets cursor column 12, line 2   
                  inputreading3 = analogread(sensor3); //getting voltage reading temperature sensor   
                  float voltage3 = inputreading3 * aref_voltage; // converting reading voltage
                  voltage3 /= 1024.0;
                  lcd.print(voltage3, 2);  //print actual voltage lcd
                  delay(200);
                 
                  if(datetime.available()) {
                  lcd.setcursor(3, 1);
                  unsigned long prevtime = datetime.now();
                  while( prevtime == datetime.now() ); // wait second rollover

                  datetime.available(); //refresh date , time properties
                  digitalclockdisplay( ); // update digital clock
                  }
                 
                } 
               else if (btndowncounter == 2)
                {
                  lcd.clear();
                  lcd.setcursor(0, 0); // set cursor column 0, line 0
                  lcd.print("psi");  // print message lcd.
   
                  lcd.setcursor(5, 0); // set cursor column 6, line 0
                  lcd.print("temp"); // print message lcd
   
                  lcd.setcursor(11, 0); // set cursor column 12, line 0
                  lcd.print("depth");  // print message lcd.
               
                }
               else if (btndowncounter == 3) 
                {
                  lcd.clear();
                  lcd.println("you have entered");
                  lcd.setcursor(0, 1);
                  lcd.print(" @ menu 3");
                }
               else if (btndowncounter == 4)
                {
                  lcd.clear();
                  lcd.println("you have entered");
                  lcd.setcursor(0, 1);
                  lcd.print(" @ menu 4");
                }
           
           }
           
         
       }
 

have debounced button?


Arduino Forum > Using Arduino > Programming Questions > 3 button Menu Program.....will not update sensor input


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial