Created
January 5, 2023 06:13
-
-
Save balp/99c75de9265e611694e2afeecd9fad4c to your computer and use it in GitHub Desktop.
Arudion Sweden Code Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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