Go Down

Topic: Little problem with UTFT Buttons and UTFT SDRaw. (Read 2003 times) previous topic - next topic


I have another question that could seem stupid but...how am I supposed to use the toggle? I mean, the objective is to "do something" for example turn a pin high or low when the button is toggled on or off. should I use switch case? thank you again very much
"The S2000 is nothing so much as a legend in its own time. If you don't like it, you probably haven't driven it hard enough." - Car culture


no just use the basic toggle method.

Code: [Select]
static byte lastState = 0, tog = 0;
byte buttonState = myTFT.getTouchState();

if( buttonState != lastState )
  if(buttonState == HIGH)
    tog = !tog;
  lastState = buttonState;

if(tog == true)
  // do something here
else {
 // do nothing

My GitHub:

Go Up