Skip to content

Instantly share code, notes, and snippets.

@macklinu
Created April 11, 2013 15:16
Show Gist options
  • Select an option

  • Save macklinu/5364219 to your computer and use it in GitHub Desktop.

Select an option

Save macklinu/5364219 to your computer and use it in GitHub Desktop.
arduino timer pseudocode
float t_random[numLeds]; // random timer
float t_reset[numLeds]; // reset timer
if (millis() - t_random[i] > t_reset[i]) { // when you've surpassed a random time for an LED
toggle_led[i]; // turn it on
t_reset[i] = millis(); // make the reset time the current time
t_random[i] = random(bottomRange, topRange); // create a new random timer value for that LED
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment