   motorSpeed = map(
     speedInPercentage,
     0, 100,
-    0, 255
+    0, maxMotorSpeed
   );
   
   Serial.print(String("Set speed to ") + motorSpeed + " ("+ speedInPercentage +"%)\n");

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

int motorSpeed = 100;
bool isMovingForward = false;
bool isMovingBackward = false;
bool safetyDriveMode = true;

{
  int currentMotorSpeedInPercentage = map(
    motorSpeed,
    0, maxMotorSpeed,
    0, 100
  );
  
