Skip to content

Instantly share code, notes, and snippets.

@shiffman
Created November 24, 2013 02:06
Show Gist options
  • Save shiffman/7622450 to your computer and use it in GitHub Desktop.
Save shiffman/7622450 to your computer and use it in GitHub Desktop.
Triggering events based on time.
int state = 0;
int time1 = 2000;
int time2 = 5000;
void setup() {
}
void draw() {
int now = millis();
if (now > time1 && state == 0) {
// trigger event 1
println("EVENT 1 " + now);
state = 1;
} else if (now > time2 && state == 1) {
// trigger event 2
println("EVENT 2 " + now);
state = 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment