Skip to content

Instantly share code, notes, and snippets.

@ilyakh
Created April 10, 2013 00:06
Show Gist options
  • Save ilyakh/5350572 to your computer and use it in GitHub Desktop.
Save ilyakh/5350572 to your computer and use it in GitHub Desktop.
class State {
public:
int id;
String name;
} currentState, previousState;
void setup() {
// serial
Serial.begin( 9600 );
Serial.println( "hailing" );
State states[5];
states[0] = State();
}
void loop() {
}
void state_1() {
Serial.println( "Entered state a" );
changeState( 0, 1, 2000 );
}
void state_2() {
Serial.println( "Entered state b" );
changeState( 1, 0, 1000 );
}
void changeState( int previous, int current, int time ) {
// 'previous' - state you are in now;
// 'next' - state you are heading to;
// 'time' - the delay that the transition will take
// blocks the system, in milliseconds.
previousState = previous;
currentState = current;
delay( time );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment