I would like to set a button on our joystick to set a motor output to full when it is pressed, then to off when it is pressed the second time, full on 3rd press, off on 4th press, etc. Any help is greatly appreciated.
It sounds like you need an edge detector and a rising edge detector.
The attached image shows that when the Boolean values are not equal, that is an edge. Either the value went false->true or true->false. In both of these you want to change the motor speed. The Greater than node indicates it was false->true and sets the motor to 1, the other sets it to zero.
Thanks for your help. I just have a quick question regarding the false case selector. I used a local variable to save the previous output and then in the false case, read from that local variable. Is this the best way to solve the “Missing Assignment to Tunnel” error, or is there a better way?
I’m not sure your description of what you want to do matches what Greg suggested. Are you just trying to toggle a motor between on and off each time you press a joystick button? There are plenty of posts here explaining how to do that; just search “button toggle motor”. Here’s one that looks particularly straightforward:
Sorry if my diagram confused you. I was using a comment for the button code and for the motor code. There is no reason to use a local if you update the motor speed inside the true case.