Skip to content

Arduino library for calling back a function, when the specified time has elapsed

Notifications You must be signed in to change notification settings

notisrac/TimeoutCallback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeoutCallback

The TimeoutCallback library makes it easy to handle events that need to occur after a specific time. For example debouncing a button.

#include <TimeoutCallback.h>

// instantiate the class
TimeoutCallback tc;

// this function will be called once the timeout has expired
void callMe(int value) // must have an int param!
{
	Serial.println("called me");
	// restart the event
	tc.Start(5000);
}

void setup()
{
	Serial.begin(115200);
	// start the callback event: it will call callMe after 3seconds
	tc.Start(&callMe, 3000);
	// you can specify an int parameter to pass to the callback function
	//tc.Start(&callMe, 99, 3000);
}

void loop()
{
	// we need to periodically call the update function, so the library knows the elapsed time
	tc.Update();
}

Analytics

About

Arduino library for calling back a function, when the specified time has elapsed

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages