consider
int count = 0;
unsigned long msecLst;
#define TWO_SEC 2000
void setup() {
Serial.begin (9600);
}
void loop() {
unsigned long msec = millis();
if ( (msec - msecLst) > TWO_SEC) {
msecLst = msec;
Serial.println (count);
count = 0;
}
};