Skip to content

Instantly share code, notes, and snippets.

@jbobrow
Created January 26, 2018 17:22
Show Gist options
  • Save jbobrow/4a917ae53d3d55cef7f2570c3904a511 to your computer and use it in GitHub Desktop.
Save jbobrow/4a917ae53d3d55cef7f2570c3904a511 to your computer and use it in GitHub Desktop.
Blinks Timer example
/*
* How to use timers
*
* by Jonathan Bobrow
* 1.25.2018
*/
#include "blinklib.h"
Timer alarm;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
if(buttonSingleClicked()) {
alarm.set(5000);
}
if(alarm.isRunning()) {
setColor(OFF); // clear the display
setFaceColor((millis()/100) % 6, RED); // animate in a circle
}
if(alarm.isComplete()) {
setColor(OFF); // turn off the display
alarm.stop(); // stop the timer
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment