martinius96

Untitled

Feb 25th, 2021
852
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int relayInput = 4; // the input to the relay pin
  2. boolean relayStatus;
  3. unsigned long time1 = 0;
  4. boolean relayStatus = false;
  5. unsigned long turnOnDelay = 1000;
  6. unsigned long turnOffDelay = 60000;
  7.  
  8. void setup() {
  9.   pinMode(relayInput, OUTPUT); // initialize pin as OUTPUT
  10.   digitalWrite(relayInput, LOW);
  11. }
  12.  
  13. void loop() {
  14.   if ((relayStatus == false) && (millis() - time1 >= turnOnDelay)) {
  15.     time1 = millis();
  16.     digitalWrite(relayInput, HIGH); // turn relay on
  17.     relayStatus = !relayStatus;
  18.   }
  19.  
  20.   if ((relayStatus == true) && (millis() - time1 >= turnOffDelay)) {
  21.     time1 = millis();
  22.     digitalWrite(relayInput, LOW); // turn relay off
  23.     relayStatus = !relayStatus;
  24.   }
  25. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×