January 12, 2016 at 3:42 pm #3177killerwhatParticipant
Hello, me again!
How do I use an input to interrupt a running loop instantly? Trying to program a simple bump-n-reverse function using if-then-else but it takes too long to react 🙁
Help please !January 12, 2016 at 3:59 pm #3179winkleinkParticipant
From the code the wait commands are stopping everything so no input can be received.
Means A is only read every 3 seconds
What are you trying to do?
I’ve attached code for the robot to go forward and if A is high to reverse a little and turn.
The default is go forward
Only the A High test is in the Forever loop.January 12, 2016 at 4:07 pm #3181killerwhatParticipant
Hi, thanks for the quick reply.
I was trying for a program that controls a continuous go-turn-go-turn-go etc but would respond if it bumped into an obstacle by backing away, turning and then carrying on as before.January 12, 2016 at 4:44 pm #3182winkleinkParticipant
OK, see revised attached code
If you use this instead of the Wait in the Else part of your code then it will allow the button to be read even during the Wait.
It counts to a 100 and waits 20ms each time. Totaling 2000ms or 2 seconds.
Revised accordingly for the 1s Wait.October 20, 2016 at 6:43 pm #3928DaveParticipant
There isn’t a proper interrupt in the crumble language as far as I know
- You must be logged in to reply to this topic.