wouldn't a long
type be preferable for usDelay (32 bits versus 16 on small arduinos)
Yes... I did not see that, and I couldn't understand why I needed to limit the multiplier... thank you for noticing... I will make a note in the sketch above.
you still have a limit (much higher) as the timeout * multiplier
is and unsigned long
that you try to fit into a signed long because the way you coded that for loop, you need to be able to deal with negative numbers for usDelay > timeout
to be effective.
Probably, because the sketch was intended to be a proof of concept for not using more libraries and still have adjustable acceleration.
timeBegin is an unsigned long
It is set to millis() before the servo move
Why would it be 0? Pretty sure it took at least a few milliseconds to get to this point?
Even if timeEnd came immediately after, with the servo move loop being skipped, it should have a value very close to timeBegin, i.e. probably not 0.
Definitely not. There are no delays is setup() and loop(). The first time timeBegin
is set, millis() returns 0. There are only about 300µs from starting the millis() counter up to this point. You can check if you print micros() at that point.
Ah. Good point. I stand corrected.