So I'm building a self-propelled vehicle made up of 3 wheels and want them all to stop spinning after after given amount of seconds/milliseconds. How would I write the programming to do so? Right now they just spin forever. This is what I currently have for just wheel/motor:
@rw950431 do you have any idea how I could do this: " Eventually you need some kind of logic that sets stop1 to a future time according to make the motor run again."
because I'm trying to make a loop with a Button. When the button is pressed it stops running the dc motor after 3 seconds, but the next time I press the button it does not work. Any idea how I could code, so the button works everytime it is pushed t?
No. That is a terrible thing to show somebody new. millis() variables are 'unsigned long' and unsigned math is always guaranteed to work when you do subtraction to calculate elapsed time. Never project out into the future and wait for millis() to catch up. In this case, it works, but will not if this is a long running program and millis() every rolls over.