Skip to content

Instantly share code, notes, and snippets.

@balp
Created January 5, 2023 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balp/99c75de9265e611694e2afeecd9fad4c to your computer and use it in GitHub Desktop.
Save balp/99c75de9265e611694e2afeecd9fad4c to your computer and use it in GitHub Desktop.
Arudion Sweden Code Example
#include "Arduino.h"
#include "Timer.h"
cpnst int PIN = 15;
const int LED = 2;
Timer timerHandler;
class RelayReset : public Timer::CallbackInterface {
public:
virtual ~RelayReset() {}
virtual void onTimeout() {
}
} relayReset;
class LedReset : public Timer::CallbackInterface {
public:
virtual ~LedReset() {}
virtual void onTimeout() {
digitalWrite(LED, LOW);
}
} ledResty;
class ButtonChecker : public Timer::CallbackInterface {
public:
ButtonChecker() : oldValue = 0 {}
virtual ~ButtonChecker() {}
virtual void onTimeout() {
current_value = digitalRead(PIN);
if(old_value == 0 && current_value == 1) {
digitalWrite(LED, HIGH);
timerHandler.addTimer(relayReset, 1000, true);
timerHandler.addTimer(ledResty, 60000, true);
}
old_value = current_value;
}
private:
int old_value;
} buttonChecker;
void setup()
{
pinMode(PIN, INPUT);
pinMode(LED, OUTPUT);
timerHandler.addTimer(buttonChecker, 100, true);
}
void loop()
{
unsigned long timeout = timerHandler.handleTimeouts();
delay(timeout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment