From 6e148d2dbf95318b5e47547c50f44b5c1b082595 Mon Sep 17 00:00:00 2001 From: David R Forrest Date: Mon, 1 May 2023 11:34:31 -0400 Subject: [PATCH 1/2] 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); + } } From 19e0ab8a425cd301f453ad1b8e96dc193f8e6812 Mon Sep 17 00:00:00 2001 From: drf5n Date: Mon, 30 Sep 2024 01:24:35 -0400 Subject: [PATCH 2/2] Update PID_RelayOutput.ino --Set the pinMode Set `pinMode(RELAY_PIN,OUTPUT)` since it is default configured as an INPUT. --- examples/PID_RelayOutput/PID_RelayOutput.ino | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/PID_RelayOutput/PID_RelayOutput.ino b/examples/PID_RelayOutput/PID_RelayOutput.ino index 7c19203..029eda3 100644 --- a/examples/PID_RelayOutput/PID_RelayOutput.ino +++ b/examples/PID_RelayOutput/PID_RelayOutput.ino @@ -33,6 +33,8 @@ unsigned long windowStartTime; void setup() { + pinMode(RELAY_PIN,OUTPUT); + windowStartTime = millis(); //initialize the variables we're linked to @@ -67,6 +69,3 @@ void loop() } } - - -