Need some help with timers

I’m am working on some lighting animations for our robot this year and during testing, I was using Timer.delay() for most of the functions such as filling up the strip from the middle to outside or from one side to the other. I soon realized that the delay function halts the thread the code is running on and I wondering what would be the best way I could set up a timer that would not cause any issues with the robot running normally.

Link to code:

Make a counter variable you increment every loop. Then instead of checking time passed you check loops taken.

1 Like

Create a Timer instance and use the reset() and hasElapsed() or advanceIfElapsed() functions to determine if a certain amount of time has passed and optionally reset the timer.

You win. At least if you need precise time.

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