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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions examples/PID_RelayOutput/PID_RelayOutput.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,6 +33,8 @@ unsigned long windowStartTime;

void setup()
{
pinMode(RELAY_PIN,OUTPUT);

windowStartTime = millis();

//initialize the variables we're linked to
Expand All @@ -55,10 +59,13 @@ 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);
}

}