Hi Everyone!,
I solved this issue and how do I close the post? Although, I do have one more question about arrays (see below).
Full code is above and here are the very minor changes to fix it.
2 Errors for those that may see this in the future and want to solve a similar problem..
Error 1) On the Flags, the variable high and low did not work for some reason and above my experience level but I found that using a counter worked.
Example: Current time = millis() and SetTime = when you want to start the clock. Say the timer millis() is at 10000 and you hit SetTime, the SetTime will now be 10000. If you want a function to act in 10 sec = 10000 millis, the millis time will now be at 20000 - 10000 for the locked set time = 10000 for the 10 sec. The flag error was that the 0 and 1 for on/off did not work for some reason but the counter method worked fine to simulate an array. counter 1 = step 1, counter 2 = step 2, ect.
if ((CurrentTime - SetTime >= Timer1) && (CounterFlag == 1))
Error 2) is that my times used as int went too high and you need to use long Timer1 = 300000. This will allow you use very high numbers because 300000 = 5 mins.
*** Now for my final question...I would like to know how to use functions within the array and not just send a array bit. ***
Example: 1000UL and enable_motor1();, 2000UL and enable_motor2, ect.;
or how can I get it to work?
// 1 sec, 2 sec, 45 sec, 60 sec and 5 mins.
unsigned long timeArray[] = {1000UL, 2000UL, 45000UL, 60000UL, 300000UL,};
int dataArray[] = {1,2,45,60,300,};
byte arrayIndex = 0;
void loop(){
currentTime = millis();
if (currentTime >= timeArray[arrayIndex]){
Serial.print("Time elapsed (sec) = ");
Serial.println (dataArray[arrayIndex]);
arrayIndex = arrayIndex +1;
if (arrayIndex == 4){
arrayIndex = 0;
}
}
}