its probably a really answer but it one i don’t know. Can someone help me with it. I have a code for when the button 6U is pressed it will run some different motors. We program this using a boolean loop. The only problem is that we find that the code is reading the button values to fast (By the time u press the button it has turned off the motors and started them again). Is there a way we can add a time to it to only read the button values every 0.5secs… Any help is great.
A waitUntil is Different from an if-else statement. Its a Natural Language command like your untilBump or untilButtonPress. Think of it as a wait except instead of waiting for a time value, it waits for its desired condition to be met.
If you want to do a push to start, push to stop type of system, a solution has already been posted. That solution is not the best (as the rest of your program will not react to commands if you were to hold the button), but it is simpler and should work well enough.
Alternatively, you could do something that when the button is pressed the motor runs, while it’s not pressed it doesn’t:
Also, to make your posts easier to read, please use the CODE tags. When writing a post (in the advanced one, not quick reply) it is the number symbol (“hashtag”) in the bar of options at the top.
waitUntil is pretty much like doing this:
while(!condition) //Keeps on looping while the condition is not yet met
{}