Now I know both solutions work but what I wonder is which is the fastest, meaning which of the two slows down the code the least (uses the least processor power)
unsigned Counter = 0;
void loop()
{
if (Counter++ > 1000)
{
Counter = 0;
// DO STUFF
}
}
That won't save any power over any other solution that does not involve a sleep mode. The advantage of the millis() version is that you can specify exactly how often you want to DO STUFF. The counter version will depend on how long it takes to do whatever else is happeneing in loop(). Are you trying to save battery power? If so you will have to use sleep.
So all in all it seems the millis function is about 2x as slow as the variable counter. Although obviously the variable counter is depending on the rest of the code.
I suspect we are comparing (counting) oranges and apples here
the millis() solution will wait roughly the number of milliseconds in the test (100 in your timed example)
whereas anything based on counter++ will just iterate the counter a number of times (again 100 in your timed example)
now unless counter++ takes 1 millisecond (which would be remarkably long) I would expect that technique to be oodles faster
(hmm what datatype does oodle() return?)
so it depends what you are trying to do here
a) delay a fixed time
b) count a number of iterations
I hope that makes sense (it did in my head when I wrote it)