Switching through cases too fast in FSMs

I am using FSMs to make presets for my arm and it is cycling through the cases to fast and I don’t know how to delay it.
I tried it virtually with enums as numbers on debug stream line and it skips states it looks like. Here is my code.

enum Presets
{
Low,
High,
HighScored,
LowScored,
Down
};
Presets preset;
void Arm()
{
writeDebugStreamLine(“%d”, preset, 1);
switch(preset)
{
case Down:
if(vexRT[Btn6U] == 1)
{
preset = Low;
}
else if(vexRT[Btn6D] == 1)
{
preset = LowScored;
}
break;
case Low:
if(vexRT[Btn6U] == 1)
{
preset = High;
}
if(vexRT[Btn6D] == 1)
{
preset = LowScored;
}
break;
case High:
if(vexRT[Btn6U] == 1)
{
preset = Low;
}
else if(vexRT[Btn6D] == 1)
{
preset = HighScored;
}
break;
case LowScored:
if(vexRT[Btn6U] == 1)
{
preset = Low;
}
else if(vexRT[Btn6D] == 1)
{
preset = Down;
}
break;
case HighScored:
if(vexRT[Btn6U] == 1)
{
preset = High;
}
else if(vexRT[Btn6D] == 1)
{
preset = Down;
}
break;
}
}

The problem is your loop keeps looping before the button is released.

You need some sort of logic to wait until any buttons are released before moving on with the loop. A simple implementation would be putting


while (vexRT[Btn6U] || vexRT[Btn6D]) { delay(20); }

at the bottom of your loop.

We used a similar scheme in NBN. To prevent the looping issue we used something like this:

else if(vexRT[Btn6D] == 1)
{
clearTimer(T1);
preset = Down;
while(time1(T1) < 500)
{}
}

That gave the driver a half second to release the button before the next loop.