Created
April 10, 2013 00:06
-
-
Save ilyakh/5350572 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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