This may be a better explanation of what i am doing.
The 2 led's represent the 2 solenoids that the relays are controlling.
this is mounted about 2ft from the solenoids, and everything is powered through a transformer.
at the end of the day, everything stays as is, and i only swap the uno out.
so that's why i was thinking the 6 slaves, into one master (uno or Mega) and a rotary switch to power the selected slave.
david_2018 mentioned using switches, what would be the proper terminology to search for, to read up on that.
Below is one of the sketches that i run, the only thing that changes from 1 sketch to the next is the values of the 1st 12 const int's which determine the delays, the number of loops, number of cycles, and the duration each relay is activated, .
in the example below, once powered up
2 hour delay,
Mrelay activated for 5min, 10 min delay, Srelay activated for 5min, 10 min delay:
repeat 5 times
5 hour delay
Mrelay activated for 5min, 10 min delay, Srelay activated for 5min, 10 min delay:
repeat 2 times
4 hour delay
Mrelay activated for 5min, 10 min delay, Srelay activated for 5min, 10 min delay:
repeat 2 times
completed for the day
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // Create an LCD object with the I2C address
const int FirstDelay = 7200000; // Define Inital Delay Period Before 1st Phase (in milliseconds)
const int fdloop = 1; // number of times to loop 1st delay
const int CyclesPhOne = 5; // Define Cycles in Phase 1
const int SecondDelay = 18000000; // Define Delay between Phase 1 & 2 (in milliseconds)
const int sdloop = 1; // number of times to loop 2nd delay
const int CyclesPhTwo = 2; // Define Cycles in Phase 2
const int ThirdDelay = 14400000; // Define Delay between Phase 2 & 3 (in milliseconds)
const int tdloop = 1; // number of times to loop 3rd delay
const int CyclesPhThree = 2; // Define Cycles in Phase 3
const int MRelayDuration = 300000; // Define Length of M Cycle (in milliseconds)
const int SRelayDuration = 300000; // Define Length of S Cycle (in milliseconds)
const int DelayBetween = 600000; // Define Length of Delay between Ming Cycle and S Cycle (in milliseconds)
const int SRelay = 2; // Define Relay Pins
const int MRelay = 3; // Define Relay Pins
int totalcycles = CyclesPhOne + CyclesPhTwo + CyclesPhThree;
int fd = 0; // Loop Counter for First Delay
int sd = 0; // Loop Counter for Second Delay
int td = 0; // Loop Counter for Third Delay
int fc = 0; // Loop Counter for First Cycle
int sc = 0; // Loop Counter for Second Cycle
int tc = 0; // Loop Counter for Third Cycle
void setup() {
pinMode(13, OUTPUT); // Set pin D13 as an output for LCD power
digitalWrite(13, HIGH); // Set pin D13 to HIGH (5V)
lcd.init();
lcd.backlight(); // Turn on the backlight
pinMode(SRelay, OUTPUT);
pinMode(MRelay, OUTPUT);
digitalWrite(SRelay, LOW); // Ensure SRelay is off initially
digitalWrite(MRelay, LOW); // Ensure MRelay is off initially
}
//////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// Do nothing after completing the cycles
if (fd < (fdloop)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = (FirstDelay - DelayBetween) / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("Daily Cycle Part 1:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
fd += 1;
}
}
else if (fc < (CyclesPhOne)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("M:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("M Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(MRelay, HIGH); // Turn the Relay on
delay(MRelayDuration); // Duration of Ming
digitalWrite(MRelay, LOW); // Turn the Relay off
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("S:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("S Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(SRelay, HIGH); // Turn the Relay on
delay(SRelayDuration); // Duration of Ming
digitalWrite(SRelay, LOW); // Turn the Relay off
fc += 1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
else if (sd < (sdloop)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = (SecondDelay - DelayBetween) / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("Daily Cycle Part 2:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
sd += 1;
}
}
else if (sc < (CyclesPhTwo)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("M:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("M Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(MRelay, HIGH); // Turn the Relay on
delay(MRelayDuration); // Duration of Ming
digitalWrite(MRelay, LOW); // Turn the Relay off
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("S:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("S Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(SRelay, HIGH); // Turn the Relay on
delay(SRelayDuration); // Duration of Ming
digitalWrite(SRelay, LOW); // Turn the Relay off
sc += 1;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
else if (td < (tdloop)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = (ThirdDelay - DelayBetween) / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("Daily Cycle Part 3:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
td += 1;
}
}
else if (tc < (CyclesPhThree)) {
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("M:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("M Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(MRelay, HIGH); // Turn the Relay on
delay(MRelayDuration); // Duration of Ming
digitalWrite(MRelay, LOW); // Turn the Relay off
lcd.clear();
lcd.print("Stage V2");
for (unsigned long i = DelayBetween / 1000; i > 0; i--) {
lcd.setCursor(0, 2);
lcd.print("S:");
lcd.setCursor(0, 3);
lcd.print("Begins In: ");
lcd.print(i);
lcd.print(" sec ");
delay(1000); // Countdown every second
}
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("S Cycle #: ");
lcd.print(fc + sc + tc + 1);
lcd.print(" of ");
lcd.print(totalcycles);
digitalWrite(SRelay, HIGH); // Turn the Relay on
delay(SRelayDuration); // Duration of Ming
digitalWrite(SRelay, LOW); // Turn the Relay off
tc += 1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
else {
lcd.clear();
lcd.print("Stage V2");
lcd.setCursor(0, 2);
lcd.print("Daily Cycle");
lcd.setCursor(0, 3);
lcd.print("Complete");
while (true);
}
}