Do you think my program will work?

So I only have to use

digitalWrite(moteur,HIGH);
    delay(1000);
    digitalWrite(moteur,LOW);
    delay(500);

one time? I don't want the car to go too fast. An analog pin would be better you think?

And whythis part of code wouldn't work? Why is it wrong?

if(cm2<30,cm>30)

Thank you for your answer!