Driving for a defined distance/ autonomous car

Hello,
How can I program my autonomous arduino car to drive for a defined distance, for example 10cm ?

I am not using any position sensor. An approach is to experiment.

...

case 'f':// Front
Motor1(255,true);
Motor2(255,true);
delay(500);
break;

...

Thank you.

What are the parameters to Motor1() and Motor2()? We are supposed to guess?

Sorry.

// Funktion Motor 1 - Zugriff auf Motor 1
void Motor1(int pwm, boolean reverse)
{
analogWrite(EN1,pwm); //set pwm control, 0 for stop, and 255 for maximum speed
if(reverse)
{
digitalWrite(IN1,HIGH);
}
else
{
digitalWrite(IN1,LOW);
}
}

// Funktion Motor 2 - Zugriff auf Motor 2
void Motor2(int pwm, boolean reverse)
{
analogWrite(EN2,pwm);
if(reverse)
{
digitalWrite(IN2,HIGH);
}
else
{
digitalWrite(IN2,LOW);
}
}

Then it's (somewhat obviously):

case 'f':// Front
Motor1(255,true);
Motor2(255,true);
delay(500);
Motor1(255,false);
Motor2(255,false);
break;

My guess is:

case 'f':// Front
  Motor1(255,true);
  Motor2(255,true);
  delay(500);
  Motor1(0,true);
  Motor2(0,true);
break;

MorganS:
My guess is:

case 'f':// Front

Motor1(255,true);
  Motor2(255,true);
  delay(500);
  Motor1(0,true);
  Motor2(0,true);
break;

Oh, right. It would be so much better if appropriately defined directional constants were used instead of true/false, like FORWARD/REVERSE. Those are the first things I do now in my own code, so I don't have much practice in reading puzzles.

How can I program my autonomous arduino car to drive for a defined distance, for example 10cm ?

I am not using any position sensor.

You can't.

Without any feedback, you are simply guessing how long to wait while the motors ramp up, the car to move some distance, and the motors to ramp back down and the car to stop.

Change the surface you run the car on while you carefully measure how far it moves in some defined amount of time, the the car will have traveled a different distance in the same amount of time.

As the batteries loose charge, the time will change. It is a fool's errand to try to program a car to move an exact distance in a given amount of time without any feedback.

Even using feedback on the wheels doesn't give exact distances because the wheels slip a different amount on different surfaces, even when you're not skidding or spinning the wheels.