From 6e148d2dbf95318b5e47547c50f44b5c1b082595 Mon Sep 17 00:00:00 2001 From: David R Forrest Date: Mon, 1 May 2023 11:34:31 -0400 Subject: [PATCH] Add RELAY_ON /RELAY_OFF per https://github.com/br3ttb/Arduino-PID-Library/issues/136 --- examples/PID_RelayOutput/PID_RelayOutput.ino | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/PID_RelayOutput/PID_RelayOutput.ino b/examples/PID_RelayOutput/PID_RelayOutput.ino index 17fbe1a..7c19203 100644 --- a/examples/PID_RelayOutput/PID_RelayOutput.ino +++ b/examples/PID_RelayOutput/PID_RelayOutput.ino @@ -18,6 +18,8 @@ #define PIN_INPUT 0 #define RELAY_PIN 6 +#define RELAY_ON LOW +#define RELAY_OFF HIGH //Define Variables we'll be connecting to double Setpoint, Input, Output; @@ -55,8 +57,14 @@ void loop() { //time to shift the Relay Window windowStartTime += WindowSize; } - if (Output < millis() - windowStartTime) digitalWrite(RELAY_PIN, HIGH); - else digitalWrite(RELAY_PIN, LOW); + if (Output > millis() - windowStartTime) + { + digitalWrite(RELAY_PIN, RELAY_ON); + } + else + { + digitalWrite(RELAY_PIN, RELAY_OFF); + } }