The analog int is an inductive sensor which is triggered by a piece of metal on the track, so thats my limit switch, considering the amount of time to close the tarp is less than two minutes easily. In fact the sensor was the initial reason I was looking to replace the delay, seeing as it disrupts reading and can stop the if statement from ever occurring. As for the futuresight, its was just a test I made off of:
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 5000;
void setup()
{
Serial.begin(9600);
Serial.println("begin");
startMillis = millis(); //save the start time
}
void loop()
{ currentMillis = millis();
if (currentMillis - startMillis >= period)
{ startMillis = currentMillis;
Serial.print("there's the bacon");}}
to get a better idea of how I might capture millis once using an unsigned long and compare it to a running and repeating millis call like currentMillis. So I'm on board with subtraction, I was more curious on how I might condition the statement so I can get a reading once when the opening or closing operation starts that I can reliably call on and subtract from the elapsed millis in an if statement. Curious of any suggestions.
As for the brackets, I was just happy the code worked, but I'll be sure to try and look up how to make that look better, and add states that define when the tarp is open closed opening closing etc. as to not potentially try to open an open tarp, seems like a good safety.
As for the precedence of operators, I don't quite know what you're referring to but I'll see what I can dig up
Thanks