Hello,
I'm wondering what would be the best method to code for the following:
I have a DC motor that I want to power for a set amount of time. I have two toggle switches. When the first toggle is on I'd like to run the DC motor forward for about 200msec and then stop and stay stopped until the toggle is turned off. The second toggle I'd like to do the same, just for 300msec then stop, again until the toggle is off.
Also, when either toggle is turned off, I want to repeat the action, but I will use an H-bridge to apply opposite polarity power to the motor and bring everything back to starting position.
I guess the real question has to deal with what happens after I tell motor to move. I can digitalWrite HIGH with a certain delay to get my movement. But then how do I prevent the VoidLoop from repeating same action? I could easily use an IF or WHILE loop were the motor to keep moving, but how do I get action and then a 'hold'? The only thought I had was to use a super long delay (hours/days) after the moving the motor, but that doesn't seem very elegant, and I'm sure that's not really how to code it.
Thanks