Control Stepper Motor with Potentiometer and display Potentiometer value on lcd screen

Hello there, im new in arduino so sorry in advance.
i search to control a stepper motor with a potentiometer (that's part work nicely)
and display the potentiometer on a lcd screen ( that part work well too)
but when i combine both of my program, my motor work in spurts.
I know thats from the lcd display delay at the end but idk how to fix that
Please Help

My Program :

#include <LiquidCrystal.h>
#include <Stepper.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
const int stepsPerRevolution = 300;  
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 13);

void setup() {
lcd.begin(16,2);
lcd.clear();
}

void loop() {
  int sensorReading = analogRead(A0);
 int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
 
  if (motorSpeed > 0) {
    myStepper.setSpeed(motorSpeed);
    myStepper.step(stepsPerRevolution / 100);
  }

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Vitesse Plateau");
  lcd.setCursor(6, 1);
  lcd.print(motorSpeed);
  lcd.print(" %");
  delay(100);
    }
  

There should be no reason to redraw this every time through loop.
You also don't need to redisplay motorSpeed if it hasn't changed

Thank for you answer.
I put lcd.print("Vitesse Plateau"); in the setup.
But i dont really see how to don't display if unchanged.

Installation and Troubleshooting is for Problems with the Arduino itself NOT your project. It says so in the description of the section. Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

You have two variables where you hold the current value of a variable and the last value of the variable. You only update the display when those two variables are different.

See the state change example code from the examples menu in the IDE.

Thank you for anwer.
I'm sorry, new with forum too.
I will try what you said.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.