|
Run a series of instructions when button is pressed
Hi all,
I'm trying to figure out how to 'automate' our shooting process. Currently in teleop we simply have a button wired to a solenoid: true means forward, and reverse means back.
When a button is held down, we want the solenoid to go forward and back four times in a certain amount of time.
What I've tried is putting a global variable that is true when the button is pressed. This gets passed to periodic tasks where if true, it runs a for loop four times. This outputs to another global variable that is passed to teleop that controls the solenoid (forward or reverse).
It doesn't work as programmed. Does anybody have any ideas? I considered putting an autonomous-style loop in teleop, but is that the optimal solution?
Any suggestions are greatly appreciated!
|