Saturday, April 12, 2014

Example of using SimpleTimer Library for Arduino

This example show how to use the SimpleTimer Library for Arduino on Arduino Due to trigger a callback function in every 500ms, to toggle LED and send somethinf to Serial port. SimpleTimer is simple library to launch timed actions. Before you can use the library, you have to install it in your sketchbook/libraries folder, read Installation.

#include <SimpleTimer.h>

int led = 13;

SimpleTimer simpleTimer;
boolean ledon;
unsigned long lasttime;
unsigned long now;

void setup() {
    pinMode(led, OUTPUT);
    simpleTimer.setInterval(500, callback_SimpleTimer);
    lasttime = millis();

void loop() {;

void callback_SimpleTimer(){
    now = millis();
    digitalWrite(led, ledon = !ledon);
    Serial.println(now - lasttime);
    lasttime = now;

1 comment:

  1. hello mate if u read this please notice that the backgroudn of the code and the black font is really hard to read :)