View Single Post
  #3   Spotlight this post!  
Unread 30-10-2014, 10:32
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,855
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Turning a button into a switch

You also need a check to keep from rapidly toggling while the button is held momentarily.
A check that requires releasing and pressing the button again for it to toggle.

e.g.,

Code:
if (button == true & button /= previous_button_state)  
         button_toggle = !button_toggle

previous_button_state = button

if (button_toggle == true)
         do something
else
         do nothing
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 30-10-2014 at 10:42.