I'm working on project right now and I think timers might be able to help me acchive what I'm trying to do. In Pseudocode, I want to be able to do this:
Start timer
For i in n:
// Do work....
If elapsed time is less than wait:
hold until the elapsed time is greater than wait.
// Do something else..
Restart timer
I've seen a few timers available for the Arduino, but I don't know which one to pick. Something with microsecond resolution would be ideal.
CuddlyKittens11:
I'm working on project right now and I think timers might be able to help me acchive what I'm trying to do. In Pseudocode, I want to be able to do this:
Start timer
For i in n:
// Do work....
If elapsed time is less than wait:
hold until the elapsed time is greater than wait.
// Do something else..
Restart timer
I've seen a few timers available for the Arduino, but I don't know which one to pick. Something with microsecond resolution would be ideal.
Look at the 'blink without delay' example in the IDE or here, in the learning/examples page. Read it, learn it and embrace the principle. You can use either millis() or micros(), whichever is more suited to your project.
I was late but yes, millis() or in your case micros() will be helpfull to track the background time elapsed. You should learn the basics of the state machine concept too.