how to program a button lock v5


#1

My team was wondering how to program a button lock on VCS. we want to be able to press a button to start the motor and press a button again to turn it off.
button Qs.PNG


#2

Right now you are using the .pressing() command which returns a Boolean for the button is being held down. If you want an action to perform after a single press of the button, use the .pressed() comment. Have it outside the while loop and have it call a method in which it will maybe change the state of a variable to 0 or 1. Then, if the variable is 0 do one action, but if it is 1, do the other.