Live updating of LCD display

So I’m very new to arduino and programming and basically have just been piecing together parts of code to get where I am so far. So please be patient in my ignorance. So far I have everything working but I’m trying to refine it a little further, which is where I’m getting stuck.

What I’m trying to accomplish is to use an UNO and two potentiometers to independently control the ON and OFF time of a pulsing DC motor. I would like to use an LCD to display to show what the ON and OFF times are. Right now I have all that working. What I would like to refine more is the updating of the values on the LCD. Right now the LCD only updates the values after the code ends and the start of the loop begins again. So if I’m making an adjustment I have no idea what I’m adjusting the value to, unless I press reset immediately after or until the code loop ends and restarts or pressing (which can be awhile as I plan to adjust the code to allow for up to 5 mins of ON or OFF time). What I would like is for the LCD to update “live” as I adjust the potentiometers.

You’ll also see some switches on the LCD to turn off the screen and the backlight (I know, not the best solution as I have to press reset to bring back the LCD after cutting power to the VCC terminal). Is there a way to eliminate the switches and have the LCD “wake up” after one of the potentiometers changes value? Then turn back off after 5 seconds? Just trying to save power to maximize battery life.

Please feel free to point out my mistake in the circuit or programming, like I said I’m new to Arduino and my only programming experience is with GCode which is unrelated.

Thanks for the help, my code is below, attached is a diagram and schematic

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // set LCD driver pins
int lcdbl = 10;  // lcdbl=LCD Backlight: hooking up the lcdbacklight to pin 10
int sensorPin = 0; // The potentiometer is connected to analog pin 0
int gatePin = 13; // The MOSFET GATE is connected to digital pin 13

void setup()
{
  lcd.begin(16,2); // set LCD as a 16 column, 2 row display
  digitalWrite(lcdbl, HIGH); //turn on LCD backlight
  pinMode(lcdbl, OUTPUT); // set pin 11 to output
  pinMode(gatePin, OUTPUT); //set MOSFET GATE pin to output
  lcd.print("Motor Control"); //display text
  delay(5000);
  lcd.clear();
}
void loop()
{
  int sensorValueon = analogRead(A0);  // read the ON input on analog pin A0:
  int sensorValueoff = analogRead(A1);  // read the OFF input on analog pin A1:
  float secondson = sensorValueon/204.6;  //convert sensorValueon to seconds (1023/delay(sensorValueon multiplication factor)
  float secondsoff = sensorValueoff/204.6; //convert sensorValueoff to seconds(1023/delay(sensorValueoff multiplication factor)
  
 lcd.print(secondson); //display ON time value on display
 lcd.setCursor(8,0); //move cursor to column 8 on top row
 lcd.print("ON Sec."); //display ON Sec. behind value
 lcd.setCursor(0,1); //move cursor to the first column on bottom row
 lcd.print(secondsoff); //display OFF time value on display
 lcd.setCursor(8,1); //move cursor to column 8 on bottom row
 lcd.print("OFF Sec."); //display OFF Sec. behind value
  
 digitalWrite(gatePin, HIGH); // Turn the LED on
 delay(sensorValueon*5); // Pause for sensorValueon seconds(multiplication factor = MAX On time)(recalculate float secondson when changing value here)
 
 digitalWrite(gatePin, LOW); // Turn the LED off
 delay(sensorValueoff*5); // Pause for sensorValueoff seconds(multiplication factor = MAX OFF time)(recalculate float secondsoff when changing value here)
 
 lcd.clear();
  }

Get rid of the calls to delay.

And please, please, please use code tags

Sorry, Added code tags

So I do understand delay is the problem here, but what i don't understand it how not use it and still make the on/off values adjustable and independent from each other. Anyone know of an example out there I can look at? I see the blink without delay example but cant figure out how to make the on and off values independently adjustable.

So I do understand delay is the problem here, but what i don't understand it how not use it and still make the on/off values adjustable and independent from each other.

The Arduino has a delay() function or millis() and the ability to store data.

YOU have an hourglass (corresponds to delay()) or a watch (corresponds to millis()) and paper and pencil (corresponds to variables in the Arduino sketch).

How would YOU perform the task of turning the motor on and off for variable periods of time? You could use two hourglasses, that you stare at to determine when the turn the motor on or off, flipping the appropriate hourglass upside down as needed. The problem with this approach is that you dare not look away for a second, or you'll miss when the sand runs out.

You could use the watch and pencil and paper to achieve the same result. Start the motor, write down the time, and sit back and sip some beer.

Periodically, you see of it is time to turn the motor off, knowing when you turned it on and how long it should be on. If it is, you turn it off, write down the time, and sit back and shoot the shit with the neighbors over to watch the football game.

Periodically, you see of it is time to turn the motor on, knowing when you turned it off and how long it should be off. If it is, you turn it off, write down the time, and check on the BBQ.

With this approach, you have plenty of times to do other things, like checking to see if the on interval or the off interval have changed.

Look at the blink without delay example, without delay().

Right now the LCD only updates the values after the code ends and the start of the loop begins again

Where is the actual code end you are referring to?

If you put temporary return after lcd prints , the time values will follow ( with delay ) the settings.
BUT you need to add some test delay or lcd.clear() so it does not look goofy.
Of course the lcd will not change until the test delay is done!
Than you can add the rest of the code “delay without blink fashion”.

lcd.print(secondson); //display ON time value on display
 lcd.setCursor(8,0); //move cursor to column 8 on top row
 lcd.print("ON Sec."); //display ON Sec. behind value
 lcd.setCursor(0,1); //move cursor to the first column on bottom row
 lcd.print(secondsoff); //display OFF time value on display
 lcd.setCursor(8,1); //move cursor to column 8 on bottom row
 lcd.print("OFF Sec."); //display OFF Sec. behind value

 delay(XXX); to observe 
 lcd.clear();
 return;         temporary exit loop

Or you could try this approach - use examples blinkwithoutdelay
and replace blink timers with sensor values
In pseudocode

if( sensor changed)
do your lcd print stuff
else
do whatever

 unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

PS I could not figure out , reading the schematic, how is your motor running. But if it does , never mind.