ON relay 1 and wait for 30 seconds and then turn on relay 2 and wait for next 90 seconds and then turn off both relay 1 and relay 2 for next 120 seconds and turn on rely 1 and wait for 30 seconds and then turn ON relay 3 for next 120 seconds and repeat the above cycle.
here is my program.
int pin8 = 8;
int pin7 = 7;
int pin9 = 9;
void setup() {
// Initialize the pins as outputs
pinMode(pin8, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin9, OUTPUT);
}
void loop() {
// Cycle 1: Pin 8 ON, wait 30 seconds
digitalWrite(pin8, HIGH); // Turn ON pin 8
delay(30000); // Wait for 30 seconds (30000 ms)
// Pin 7 ON
digitalWrite(pin7, HIGH); // Turn ON pin 7
delay(90000); // Wait for 90 seconds (90000 ms)
// Turn OFF both pins 7 and 8
digitalWrite(pin7, LOW); // Turn OFF pin 7
digitalWrite(pin8, LOW); // Turn OFF pin 8
delay(120000); // Wait for 120 seconds (120000 ms)
// Pin 8 ON again, wait 30 seconds
digitalWrite(pin8, HIGH); // Turn ON pin 8
delay(30000); // Wait for 30 seconds (30000 ms)
// Pin 9 ON
digitalWrite(pin9, HIGH); // Turn ON pin 9
delay(90000); // Wait for 90 seconds (90000 ms)
// Turn OFF both pins 9 and 8
digitalWrite(pin9, LOW); // Turn OFF pin 9
digitalWrite(pin8, LOW); // Turn OFF pin 8
// After completing the cycle, the program loops back to the start
}
to you setup() function, then put a print statement where the problem is, viz:
// Turn OFF both pins 9 and 8
digitalWrite(pin9, LOW); // Turn OFF pin 9
digitalWrite(pin8, LOW); // Turn OFF pin 8
Serial.println("relays have been switched off");
delay(1000); // and see what happens when you don't hang out a bit
// After completing the cycle, the program loops back to the start
}
yes, I don't want time delay to turn on pin 8 output initially but in the further loop relay not operating as expected. relay not turning OFF properly.
I think you will have to add the delay to notice the Relay turning OFF. It may also help if you tell why you dont want a delay but want to turn the relay off. This will help us give you a solution tailored to your project.