Timer Variable

jimLee:
Well, this does what you say you want.

#include <timeObj.h>

timeObj  theTimer(10000);            // A 10 second timer, starting NOW.

void setup(void) {

Serial.begin(9600);   // Start the serial stuff.
}

void loop(void) {

char  aChar;
 
  if (!theTimer.ding()) {   // If the timer has NOT expired..
     if (Serial.available()) {   // If we have a char to read..
        aChar = Serial.read();   // Read the char.
        Serial.print(aChar);   // Write the char.
     }
  }
}




Grab LC_baseTools from the library manager to get this to compile.

-jim lee

Hi Jim, thank you for your response. Do you know how I would be able to combine this with my ISR_COMPA_vect to make it stop after a certain amount of time? Many thanks.