Hi, i am currently programming a chain bar bot and was wondering if there was anything like progressive programming?
So say i was to press button 5d once and it would go to a certain setpoint, is there a way to have it go to a different setpoint the next time i press the button 5d? and if there is, is there a way to refresh it to go back to the initial setpoint? Thanks for your help!
@EvolvingJon has given you some good suggestions here.
https://vexforum.com/t/unofficial-response-to-progressive-programming/43225/1
A general approach to doing this would be using a finite state machine. The action your button has is determined by the “state” your program is in, once the button action has happened your program enters a new “state” and waits for the next command. Something like this.
task main()
{
int state = 0;
bool btnNotPressed = true;
while(1) {
if( vexRT Btn5U ] && btnNotPressed ) {
// button is pressed
btnNotPressed = false;
switch(state) {
case 0:
// move motor to position 2
state = 1;
break;
case 1:
// move motor to position 3
state = 2;
break;
case 2:
// move motor to position 1
state = 0;
break;
default:
state = 0;
break;
}
}
else
if( !vexRT Btn5U ] ) {
// button is released
btnNotPressed = true;
}
wait1Msec(20);
}
}