Implementing activate and clear
This commit is contained in:
parent
9042775f1c
commit
29ec2f7641
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
|
|
||||||
bool input1active = true;
|
#define PIN_ACTIVATE 5
|
||||||
|
#define PIN_CLEAR 2
|
||||||
|
bool inputActive = true;
|
||||||
|
bool clearActive = true;
|
||||||
|
long activateTimeout = 0;
|
||||||
|
|
||||||
static bool eth_connected = false;
|
static bool eth_connected = false;
|
||||||
|
|
||||||
@ -98,7 +102,8 @@ void setup() {
|
|||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
ETH.begin();
|
ETH.begin();
|
||||||
|
|
||||||
pinMode(5, INPUT_PULLUP);
|
pinMode(PIN_ACTIVATE, INPUT_PULLUP);
|
||||||
|
pinMode(PIN_CLEAR, INPUT_PULLUP);
|
||||||
|
|
||||||
while (!eth_connected) {
|
while (!eth_connected) {
|
||||||
delay(1000);
|
delay(1000);
|
||||||
@ -136,21 +141,34 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
if (digitalRead(5) != input1active) {
|
if (digitalRead(PIN_ACTIVATE) != inputActive) {
|
||||||
delay(10);
|
delay(10);
|
||||||
if (digitalRead(5) != input1active) {
|
if (digitalRead(PIN_ACTIVATE) != inputActive) {
|
||||||
|
|
||||||
input1active = digitalRead(5);
|
inputActive = digitalRead(PIN_ACTIVATE);
|
||||||
if (!input1active) {
|
if (!inputActive) { // React when the signal starts
|
||||||
Serial.println("Turn on");
|
if (millis() - activateTimeout >= 60000) { // 1 Minute timeout
|
||||||
|
Serial.println("Activate triggered");
|
||||||
ws.textAll("blinkLamp");
|
ws.textAll("blinkLamp");
|
||||||
} else {
|
}
|
||||||
Serial.println("Turn off");
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digitalRead(PIN_CLEAR) != clearActive) {
|
||||||
|
delay(10);
|
||||||
|
if (digitalRead(PIN_CLEAR) != clearActive) {
|
||||||
|
|
||||||
|
clearActive = digitalRead(PIN_CLEAR);
|
||||||
|
if (clearActive) { // React when the signal is over
|
||||||
|
Serial.println("Clear triggered");
|
||||||
ws.textAll("noBlinkLamp");
|
ws.textAll("noBlinkLamp");
|
||||||
|
activateTimeout = millis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(100);
|
|
||||||
|
delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user