Time = Distance / Speed

Hey guys, going to need some help here figuring out a good way to get the time of travel from the set up I have going here. Probably just overcomplicating things like I tend to :P

void setup()
{
  ST1.attach( 8, 1000, 2000);
  int a = 1 //This is the speed or power
  //1 == full forward
  //2 == medium forward
  //3 == slow forward
  //4 == slow reverse
  //5 == medium reverse
  //6 == full reverse
  
  int b = 1 //this is the distance in feet

  int c = 0 //this is time
  
  //Time == Distance / speed

}

void loop()
{
  
  if a == 1{
    power = 150;
  }else if a == 2{
    power = 130;
  }else if a == 3{
    power = 110;
  }else if a == 4{
    power = 70;
  }else if a == 5{
    power = 50;
  }else if a == 6{
    power = 30;
  }
  
  //intialize power

    ST1.write(power);

}

So all I need to do is figure out the formula I need to make to have my wheels turn x feet and x speed. The diameter of the wheels are 40 inches and the distance doesn't have to be exact but should be close. If anyone has any tips they would be greatly appreciated.

The time of travel can be got from millis() - don't you mean the distance travelled?

Also you can simplify your mapping in loop:

int a = 1 ;   // a must be global, not declared in setup()
int power_mapping [] = { 0, 150, 130, 110, 70, 50, 30 } ;  // array for mapping a value to power level

void loop ()
{
  ST1.write (power_mapping [a]) ;  // simple
  // other stuff here
}

You have a measurement for speed at various power levels. Divide the desired distance in feet by the speed in feet per second to get the number of seconds to run the motor. Multiply by 1000 to get the number of milliseconds to run the motor.

float speed_mapping [] = { 0, 5.14706, 2.69231, 0.08642, 0.97222, 2.69231, 5.14706 } ; 

void loop () {
  ST1.write (power_mapping [a]) ;
 // Wait until we've moved 2.75 feet
delay(2.75/speed_mapping[a] * 1000.0);
// Then stop
ST1.write(90); 
delay(5000);  Wait five seconds before doing it again
}