|
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.
|