scheduler
#include <Scheduler.h>
int sw = 10;
int relay1 = 6; // light module
int relay2 = 7; // water module
void setup()
{
pinMode(sw, INPUT_PULLUP);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
Scheduler.startLoop(loop2);
time = mills();
}
void loop() // water module
{
if(digitalRead(sw)==LOW)
{
digitalWrite(relay2,HIGH);
delay(1000);
digitalWrite(relay2,LOW);
delay(1000);
digitalWrite(relay2,HIGH);
delay(1000);
}
else
{
digitalWrite(relay2,HIGH);
delay(100);
}
}
void loop2() // light module
{
digitalWrite(relay1,HIGH);
delay(1000);
digitalWrite(relay1,LOW);
delay(1000);
yield();
}
#include <Scheduler.h>
int sw = 10;
int relay1 = 6; // light module
int relay2 = 7; // water module
void setup()
{
pinMode(sw, INPUT_PULLUP);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
Scheduler.startLoop(loop2);
time = mills();
}
void loop() // water module
{
if(digitalRead(sw)==LOW)
{
digitalWrite(relay2,HIGH);
delay(1000);
digitalWrite(relay2,LOW);
delay(1000);
digitalWrite(relay2,HIGH);
delay(1000);
}
else
{
digitalWrite(relay2,HIGH);
delay(100);
}
}
void loop2() // light module
{
digitalWrite(relay1,HIGH);
delay(1000);
digitalWrite(relay1,LOW);
delay(1000);
yield();
}
#include <Scheduler.h> int sw = 10; int relay1 = 6; // light module int relay2 = 7; // water module void setup() { pinMode(sw, INPUT_PULLUP); pinMode(relay1, OUTPUT); pinMode(relay2, OUTPUT); Scheduler.startLoop(loop2); time = mills(); } void loop() // water module { if(digitalRead(sw)==LOW) { digitalWrite(relay2,HIGH); delay(1000); digitalWrite(relay2,LOW); delay(1000); digitalWrite(relay2,HIGH); delay(1000); } else { digitalWrite(relay2,HIGH); delay(100); } } void loop2() // light module { digitalWrite(relay1,HIGH); delay(1000); digitalWrite(relay1,LOW); delay(1000); yield(); }
2019 03 31 Smart Farm Switch Code