Hi, thank you so much for helping me! Right now I have 5 solder boards that are based off the circuit design I am attaching below. I want the boards to work synchronously; however, I do not know how. All of the boards can turn on and blink. However, I want it so that right when I turn on the Arduino, all 5 boards will turn on and blink at the same time as well as turn off at the same time. Below is my code and I have attached 2 images: one of the solder boards and one of my circuit design. I know each board will need its own 9V battery, however, I want to connect them so that the moment I turn on the Arduino, all of the boards work synchronously. Thank you!
byte timeRunning = 0;
byte startButton = 2; // or whatever pin is used, button pin to Gnd when presses
byte ledPin = 3; // or whatever pin is used, will turn relay or MOSFET
byte onBoardLed = 13;
unsigned long startTime;
unsigned long timeNow;
unsigned long elapsedTime;
unsigned long thirtyminutes = 30 * 1000 * 60UL;
void setup() {
pinMode (startButton, INPUT_PULLUP);
pinMode (ledPin, OUTPUT);
pinMode (onBoardLed, OUTPUT);
Serial.begin(9600);
}
void loop() {
// wait for start button press, ignore if already pressed
if ((digitalRead (startButton) == LOW) && (timeRunning == 0)) {
timeRunning = 1;
startTime = millis();
Serial.print("Inside if statement for timeRunning == 0");
Serial.println(timeRunning);
}
if (timeRunning == 1) {
timeNow = millis();
elapsedTime = timeNow - startTime;
if (elapsedTime <= thirtyminutes) {
digitalWrite (ledPin, HIGH);
digitalWrite (onBoardLed, HIGH);
delay (100); // one second on time
digitalWrite (ledPin, LOW);
digitalWrite (onBoardLed, LOW);
delay (100); // one second off time
Serial.print("startTime: ");
Serial.println(startTime);
Serial.print("timeNow: ");
Serial.println(timeNow);
}
else {
// 30 minutes is up
timeRunning = 2;
Serial.println("Inside else statement");
digitalWrite (ledPin, LOW);
digitalWrite (onBoardLed, LOW);
}
}
}






