So im fairly new to Arduino, i did try to make a project a few years ago but ended up giving up.
i have some very simple skills, (the ability to turn on off relays and set delays)
i am basically trying to use a relay as a timer, however when using the delay function everything seems to pause until the delay has finished.
the problem i have is im trying to use 2x relays
relay 1 to turn a pump on and off once an hour for 10 mins
relay 2 to turn a led bulb on and off, on for 8 hours off for 16
could someone point me in the direction of where to start or an example. i have done a fair bit of googling but ive not had any luck
int WATERPUMP = 2; // relaypin for waterpump
int LIGHTS = 3; // relaypin for lights
int PumpOn = 1000; // set time for pump to be on msecs
int PumpOff = 1000; // set time for pump to be off msecs
int LightsOn = 1000; // set time for lights to be on msecs
int LightsOff= 1000; // set time for lights to be off msecs
void setup() {
// put your setup code here, to run once:
pinMode(WATERPUMP, OUTPUT);
pinMode(LIGHTS, OUTPUT);
digitalWrite(WATERPUMP, LOW);
digitalWrite(LIGHTS, LOW);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(WATERPUMP, HIGH);
Serial.println("WATERPUMP ON");
delay(PumpOn);
digitalWrite(WATERPUMP, LOW);
Serial.println("WATERPUMP OFF");
delay(PumpOff);
// delay(delayValue);
digitalWrite(LIGHTS, LOW);
Serial.println("LIGHTS ON");
delay(LightsOn);
digitalWrite(LIGHTS, HIGH);
Serial.println("LIGHTS OFF");
delay(LightsOff);
}
This is what you need to learn. Give it a try. If you get stumped, post your best try, describe what the code actually does and how that differs from what you want.