hi,
having problems with a segment of code involving elapsedMillis,
i have created a time loop so serial out prints every 1 second, this works for 32 seconds and then for some reason the function no longer executes even though it meets the condition,
i have placed serial out to check that indeed the loop is still running and monitor is still function as is. also have logged the time stamps outside the function and it makes sense.. i have a global running time and a time stamp.
ignore the function - BUTTONstate1 im not utilizing when this is running.
see below code, can anyone tell me what is going wrong.
> void B1_ARM() {
>
>
>
> if(timeElapsed_ARM > (timeStamp_ARM + 1000)){ // serial print out every 4 seconds? // if condition previous code is more than 4 seconds it will run
>
> delay(5);
> Serial.print("Scanning B1_ARM function for Trigger.."); // testing breach point
> Serial.println();
> Serial.print("button state: ");
> Serial.print(BUTTONstate1,DEC);
> Serial.print(" DAstate: ");
> Serial.print(DAstate);
> Serial.print(" breachReset: ");
> Serial.print(breachReset);
> Serial.println();
> Serial.print(" timeStamp_ARM: ");
> Serial.print(timeStamp_ARM);
>
> delay(5);
> Serial.print(" timeElapsed_ARM ");
> Serial.print(timeElapsed_ARM);
>
> timeStamp_ARM = timeElapsed_ARM; // elasped time has to be more than 4 seconds i.e 4 seconds + >> provides a place holder point in time
>
> Serial.println();
> Serial.print(" timeStamp_ARM");
> Serial.print(timeStamp_ARM);
> Serial.println();
> }
> Serial.println();
> Serial.print("outside function");
> Serial.println();
>
> delay(5);
> Serial.print(" timeElapsed_ARM ");
> Serial.print(timeElapsed_ARM);
> Serial.println();
> Serial.print(" timeStamp_ARM");
> Serial.print(timeStamp_ARM);
>
>
>
> BUTTONstate1 = digitalRead(BUTTON1);
>
> if (BUTTONstate1 == HIGH && breachReset == 0) //
> {
>
> Serial.print("button 01 ARM detected!"); // testing reach point
> Serial.println();
>
> digitalWrite(LED2, HIGH);
> delay(200);
> digitalWrite(LED2, LOW);
>
>
> diveSelect(); // call for dive profile type loop
>
>
>
>
> }
> }
also here is a snippet from serial out
timeStamp_ARM29325Scanning B1_ARM function for Trigger..
button state: 0 DAstate: 0 breachReset: 0
timeStamp_ARM: 29325 timeElapsed_ARM 30457
timeStamp_ARM30462
outside function
timeElapsed_ARM 30525
timeStamp_ARM30462
outside function
..
outside function continues to run
timeElapsed_ARM 35767
timeStamp_ARM32738
outside function
this should trigger function as timeelapsed is more than timestamp .. but does not execute.