Timeline for how to ignore a sensor being tripped the first time and start recording millis on the 2nd time it is tripped
Current License: CC BY-SA 4.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 23, 2020 at 6:59 | comment | added | Nick Gammon♦ | I am thinking it needs a line of code to have the 1st sensor == LOW once and do nothing - that's what my suggestion does. If you want it to "reset" then you need more code. I'm not quite sure what your parameters are. How do you know you are starting a new race? | |
Sep 21, 2020 at 17:01 | comment | added | chris | with changing the sketch line to "if (digitalRead(2) == LOW && start == 0)" it seems that the first millis is always the same value as the first time it was tripped but the other sensors record what looks to be correct numbers. | |
Sep 21, 2020 at 16:28 | comment | added | Ananas_hoi |
You could also declare start as a static in the loop: static long start = millis(); . That way it gets called only the first time, and will remember the var in the rest of the loop()
|
|
Sep 21, 2020 at 7:58 | history | answered | Nick Gammon♦ | CC BY-SA 4.0 |