Stoppwatch Screen

Dear Guys,

i have a question about the Seriell Port Screen for my Stoppwatch.


   if (lauf == 1)   //START Time
    {  
      starttime = millis();
      lauf = 2;  
    } else if (lauf == 2)          // Actuall Time
            {   
             zwischenzeit = (millis()-starttime)/1000;
             Time = ((millis()-starttime)/1000.0);  
             Serial.println(Time);  
            } else if (lauf == 3) // Stopp 
                    { 
                      lauf = 0;
                      finished = millis();
                      AnzeigeZeit = (millis() - starttime)/1000.0;
                      Serial.println(AnzeigeZeit);
                    }


The question is if i start the Time, the time has in seriell monitor 1 seconds delay. If i stopp the time, the time stopp and after 1 second, the seriell monitor write the correct time.

Where is the fault?

Thanks

ardu

Nesting else if will give you constipation. Changing test variables within conditional statements will make you crazy. Avoid crazy constipation and deal with logic before conditional testing and use switch case to make your choices clear.

switch...case - Arduino Reference

here was similar

The fault does not seem to be in the part of your sketch which we can see.
Therefore, the fault is, most likely, in the part of your sketch which we cannot see.

Please post your entire sketch, not just part of it.

Thanks for your fast replies,

after yesterday i have make today a complete new project, and with the code and only a start signal and stopp signal, the behavier doesn't exist. The code before was only input from seriell read with differences typs......but i will check step by step which one is the responsible for the delay.

thanks a lot guys

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.