- October 12th, 2018, 3:45 pm#4909865Its a little coding in the blind but there is not much to it. Basically you need to define what pin will be used. 13 is still available so at the top of the file where all of the pins are being defined add one for the vent
bool isRelayVenting = false; // remember what state the relay is in
const int VENT_RELAY = 13; // pin on the arduino relay is connected to
Then you have to tell the arduino what to do with that pin. This happens in the Setup() function and you would just add the following two lines anywhere in there
pinMode(VENT_RELAY, OUTPUT);
digitalWrite(VENT_RELAY, HIGH);
This configures the pin for talking to the relay and then turns the relay off. Note: some relays use logic low for activation so for this demo let's set to high to turn the relay off. Then at the bottom of the Loop() function you could add something like this
if( venting == true && isRelayVenting == false ){
digitalWrite(VENT_RELAY, LOW);
isRelayVenting = true;
}else if ( venting == false && isRelayVenting == true ){
digitalWrite(VENT_RELAY, HIGH);
isRelayVenting = false;
}
I am pretty sure that is all that there would be to it but I don't have a relay to test.