EasyC-Toggle flywheel speed

I am confused as to how I could program my robots flywheel to increase/decrease speed at the push of a button. As of now I would like to have 2 speeds and a toggle button to switch between them. I have a stationary lift and a power expander the is just for the flywheel.

Thanks!

Ry1011

You can use a variable that changes each time a button is pressed, allowing to switch between two speeds.

Pseudocode:
int variable = 0;
while(true)
{
if(button pressed && variable = 0)
{
fullmotorspeed;
variable = 1;
}
if(button pressed && variable = 1)
{
halfmotorspeed;
variable = 0;
}
}

Is this with EasyC? I think I understand if it is.

Sorry, unfortunately this is with RobotC. However, I am guessing the concept is the same with Easy C.

or you could use a boolean to toggle the high speed, but an int would allow for even more speeds, like cycling through 4 speeds

https://vexforum.com/t/programming-help-for-flywheel-speeds/30589/1
An example I made earlier in the season

As mentioned in the linked thread, (but not explained here)
1 the code posted here doesn’t work, (also need to detect change of button state, not just ‘pressed’)
2 Rather than toggle between two speeds with one button,
its easier (and better user interface) to use a different button for each speed.