Go Down

Topic: WAKEUP - a simply library to manage counters (Read 1 time) previous topic - next topic


Hi there,

i'm sharing WAKEUP my first library here.  It's a simple way to manipulate counters and timers in your sketch.
(zip attached or https://github.com/brunocadet/WAKEUP)

Example of a counter : Blinking a LED
Code: [Select]


void loop(){
if ( myLed.istime(500) ) digitalWrite( 13, !digitalRead(13) );  

Example of a timer
Code: [Select]

WAKEUP myTimer(30000);

void loop(){
if ( digitalRead(bouton) ) myTimer.go();
if ( myTimer.istime() ) Serial.print("DEBOUT LADANS!");  



TIP: make the time related variables unsigned long instead of  long ==> matches the values returned by millis() .
also for return values of some functions e.g.

Code: [Select]
long WAKEUP::remain(){
  return max(0, start+life-millis());

Code: [Select]

unsigned long WAKEUP::remain()
  unsigned long current = millis();
  if (current < start +life) return start + life - current;
  return 0;
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up