View Single Post
  #2   Spotlight this post!  
Unread 23-02-2013, 11:21
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,062
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Command-Based robot button toggle question


In order to toggle, you first have to detect the rising edge of your joystick button (because you want it to toggle only once when you press the button, not repeatedly while you're holding the button down).

Then you toggle a boolean each time a rising edge is detected. Then use the value in that boolean to determine what action to take.

For example:

Code:
button1 = getButton(1);
if (button1 && ! button1previous) toggle = ! toggle;
button1previous = button1;


Last edited by Ether : 23-02-2013 at 11:23.
Reply With Quote