millis() + modulo = unexpected result

If I run this code:

if( (millis() % 1000) == 0 ) {
  serial.print("A second has passed");
}

and expect it to print out once a second but its printing continuously.

Have I missed something? I don't see anything in the reference about modulo not working with unsigned longs...

Cheers for your help

The posted code wont compile, you need a cap S on Serial

with Serial.print it will work as you expect

That code will not execute precisely once when 'millis()' returns a multiple of 1000, but will execute many times. The buffering effect of the serial data stream may make it look as though it runs continuously. Remember that the Arduino runs at 16MHz and 'millis() % 1000' will be zero for an entire millisecond. During that millisecond, Serial.write will be called many times.

Thanks Anachrocomputer, that makes sense. Will modify the code when I get home.

I think I might be doing quite a few of these time based executions in my code ( calling something more productive that Serial.print), thinking of coding up an event scheduler. Before I waste my time does anyone know of one thats already some lib out there that would suffice?

in case anyones interested:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1217881285/4