I am trying to make a robot turn (dc motors are being used) back 180 degrees. So I used an l289n for it and made one wheel turn clockwise and vice-versa.

But as I wan't it to make only a 180 degrees turn, I wanted to set an amount of time for it to turn. Is there any other way to do the same thing, if yes, please tell, if no, help me...

  • delay() Commented Jan 20, 2016 at 14:39
  • @CharlieHanson how do you plan on using the delay function. It occurred to me once but it will just be like the wheels will turn for an undefined period of time and then there will be a delay.
    – HDatta
    Commented Jan 20, 2016 at 14:41
  • Really? turn motor 1 CW; turn motor 2 CCW; delay for some time; turn motor 1 off; turn motor 2 off. Commented Jan 20, 2016 at 14:43
  • yea maybe thats a good idea....Thnx..
    – HDatta
    Commented Jan 20, 2016 at 14:44

1 Answer 1


Use the delay() function.

Pseudo code as follows:

1) Turn clockwise motor on;
2) Turn counterclockwise motor on;
3) delay(<time>);
4) Turn CW motor off;
5) Turn CCW motor off.
  • Thank you very much....I still can't believe that this simple logic didn't occur to me :P
    – HDatta
    Commented Jan 20, 2016 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.