Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set pinMode(RELAY_PIN,OUTPUT) & add RELAY_ON /RELAY_OFF per https://github.com/br3ttb/Arduino-PID-Lib… #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

drf5n
Copy link

@drf5n drf5n commented May 1, 2023

Flesh out the logic of https://github.com/br3ttb/Arduino-PID-Library/blob/master/examples/PID_RelayOutput/PID_RelayOutput.ino to clearly accommodate both active-LOW and active-HIGH relays per #136

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);
+  }
 
 }

David R Forrest and others added 2 commits May 1, 2023 11:34
Set `pinMode(RELAY_PIN,OUTPUT)` since it is default configured as an INPUT.
@drf5n drf5n changed the title Add RELAY_ON /RELAY_OFF per https://github.com/br3ttb/Arduino-PID-Lib… Set pinMode(RELAY_PIN,OUTPUT) & add RELAY_ON /RELAY_OFF per https://github.com/br3ttb/Arduino-PID-Lib… Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant