Counting Vex Transmitter Button Presses

We want to be able to increment a variable by pressing a button on the transmitter.
Is this how we would do it? How would we prevent against accidental long presses, or would this not be an issue?


if(vexRT[Btn8RXmtr2] == 1)
      MyVar++;

So the main thing is to track when a button is pressed and not just held down. So you need to track when a button is down AND last time it wasn’t down.

	bool lastButtonValue;
	if(vexRT[Btn8RXmtr2]&&!lastButtonValue)
		MyVar++;
	lastButtonValue = vexRT[Btn8RXmtr2];