|
Re: How to loop peices of code forever?
I don't know your level of knowledge so I can give you an appropriately tailored answer. My first thought is that this should be implemented as a state machine without any delays in it. The "start" state would do nothing, and would move to the "follow the line forward" when it sees the button press. When not in the "start" state I'd have the program continually check to see whether the button has just been pressed, and set a "prepare to stop" flag if so. If the flag is set, the final "drop the block" state would transition either to a "halted" state or back to the "start" state if you want to be able to start it up again.
Doing it sequentially with delays, as in the originally posted code, will make detecting the second button press very difficult.
|