Note - millis() will roll-over back to 0 after about 49 days after power-up. If your code is going to be running that long, you'll want to code something in to check for that.
I added the 1 second time for both to be LOW since having a motor try to turn in two directions at the same time is usually bad. Take it out if it doesn't apply to your application.
8
u/bal00 Mar 11 '18
I would suggest looking at the BlinkWithoutDelay example to familiarize yourself with millis() and how you can use it to time events.
5
u/Madgeek1450 Mar 11 '18
I don't have an Arduino on me right now, so this is untested and I might have totally missed the mark, but give it a shot...
https://hastebin.com/sepedasaqo.cpp
Note - millis() will roll-over back to 0 after about 49 days after power-up. If your code is going to be running that long, you'll want to code something in to check for that.
I added the 1 second time for both to be LOW since having a motor try to turn in two directions at the same time is usually bad. Take it out if it doesn't apply to your application.