Battery Voltage

Can you help me get my Voltage variable changing because before i added the LCD Display Code Chooser i was able to see the voltage change instantly but know it doesn’t
nleos.zip (3.09 KB)

It looks like you have two nested while loops in the driver control part of your code. The second while loop will continue to run, your battery monitoring code is outside of this. Try removing the while loop at line 309 (and also the delay at line 304, that’s not needed)

287   while(true)                           // An infinite loop to keep the program running until you terminate it
288    {
289      clearLCDLine(0);                      // Clear line 1 (0) of the LCD
290      clearLCDLine(1);                      // Clear line 2 (1) of the LCD
291      displayLCDString(0, 0, "Primary: ");
292      sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
293      displayNextLCDString(mainBattery);
294   
295      string expanderBattery;
296      //* Expander Battery Displaying *//
297      if(SensorValue[Power]<2240){ //If Expander Battery is below 8V (2240 Value)//
298        clearLCDLine(1); //Clear LCD line 1 (Bottom Line)//
299        displayLCDString(1, 0, "Exp. Low: "); //Display Expander Low//
300        sprintf(expanderBattery, "%1.2f%c", SensorValue[Power]/280.0, 'V');    //Build the value to be displayed//
301        displayNextLCDString(expanderBattery); //Display the string "expanderBattery"//
302      }
303        //Short delay for the LCD refresh rate
304        wait1Msec(100);
305   
306        SensorValue[rightEncoder] = 0;    // Set the encoder so that it starts counting at 0
307        SensorValue[leftEncoder]  = 0;    // Set the encoder so that it starts counting at 0
308        //Loop Forever
309        while(1 == 1)
310        {
311          //Remote Control Commands
312          motor[frontRight] = vexRT[Ch3]+ vexRT[Ch1];
313          motor[backRight] =  vexRT[Ch3]+ vexRT[Ch1];
314          motor[frontLeft] = vexRT[Ch3]- vexRT[Ch1];