how can i make my wheels move forward

i have build an obstacle avoiding robot and my wheels are moving backwards how can i fix it to move forward

arduino.ino (3.29 KB)

If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it’s ok to add it as an attachment.

In this case your sketch is well under 9000 characters so you’re not doing yourself any favors by posting it as an attachment.

If your wheels are turning the opposite direction as what your code tells it to then you have two options:

  • Change the wiring
  • Change the code. You have a function moveForward() and another moveBackward(). What do you think would happen if you swapped the digitalWrite() statements between the two?

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

yazantariq:
i have build an obstacle avoiding robot and my wheels are moving backwards how can i fix it to move forward

You have two wires from the motor, swap them over;
so if red wire went to terminal 1 and black wire to terminal 2.
then swap them so;
red wire goes to terminal 2 and black wire goes to terminal 1.
And do the same with the other motor's connections.
Tom... :slight_smile: