Brushless Motor mit Poti und Display Anzeige

Danke für die Rückmeldungen. In der Hauptsache geht es mir darum, dass mir mal jemand über den Code drüber schaut und wie ich folgendes im Code definieren kann:

  • Stop Funktion (NotAus) mit Taster
  • Minimale Drehzahl (Motor Regler 0)
  • Maximale Drehzahl (z.B.: 60%, egal wie weit ich den Poti drehe)

Hier der aktuelle Code:

#include <Wire.h> 
 #include <LiquidCrystal_I2C.h>
 #include <Servo.h> 

 LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 20 chars and 4 line display
 Servo myservo;  // create servo object to control a servo 

 int potpin = 0;  // analog pin used to connect the potentiometer
 int val;    // variable to read the value from the analog pin 

 void setup()
 {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object  

    lcd.init();                      // initialize the lcd 
    lcd.backlight();
    lcd.setCursor(3,0);
    myservo.write(0);  // <------ put the servo at zero
    
  }

  void loop() 
  {
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  //val = map(val, 0, 1023, -10, 160);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  lcd.setCursor(0,0);
  lcd.print("Wuchtmaschine");
  lcd.setCursor(0,1);
  lcd.print("my name");
  lcd.setCursor(0,2);
  lcd.print("Balanceing Speed");
  lcd.setCursor(0,3);
  lcd.print("Prozent");
  lcd.setCursor(13,3);
  lcd.print("%");
  lcd.setCursor(10,3);
  lcd.print("   ");  // This covers up the previous value
  lcd.setCursor(9,3);
  lcd.print(val);
  delay(15);                           // waits for the servo to get there 
  }