What I need is to move a dc motor forward and reverse continuously when a push button is pressed. When the push button is pressed again, it will stop moving.
I'm currently using this coding and circuit below. However this circuit automatically move the motor forward. When the push button is pressed, the motor will reverse direction.
Please help me. I've been trying to change the coding but I'm new to this so I don't get the results up till now.
I really hope someone could help. Thank you in advance!
What I need is to move a dc motor forward and reverse continuously when a push button is pressed. When the push button is pressed again, it will stop moving.
What?
Do you have two pushbuttons, one for forward and one for reverse?
Do you want the motor to start moving back and forth (like, once per second) when a button is pushed, and stop moving when it is pushed again?
Do you want to go forward when a button is pressed, then stop when it is pressed again, then go backward when it is pressed again, then stop when it is pressed again, and so on in a cycle?
If you can't explain in regular language what you actually want the arduino to do, then you won't be able to explain it to an arduino (which, after all, is what programming actually is).
(ps: as mentioned in point 6 in the sticky post, don't bother saying something is urgent. Sorting out your personal schedule is your problem and not anyone else's.)