/*The following code can be added to you sketch to allow the use of the Timer interrupt to read a GPS character ~1 millisecond*/ boolean usingInterrupt = false; /* This variable that is changed when the interrupt is turned on and off. It can be used to check if there is an interrupt is on or off*/ ISR(TIMER0_COMPA_vect) { /******* Interrupt Service Routine ************************************************ * This is the interrupt service routine. It reads a character from the GPS. **********************************************************************************/ GPS.read(); // Read a character from the GPS } void useInterrupt(boolean v) { /******* useInterrupt ************************************************************* This function is enables or disables the Timer interrupt. So **********************************************************************************/ /* millis() uses Timer0, so we'll interrupt at the half millisecond point (ie 0.5, 1.5 ... ) that prevents interference with millis which happens at the top of the millisecond (ie 1.0, 2.0 ..) */ if (v) { OCR0A = 0xAF; //This line controls when the trigger happens from 0 (very start) to 255 (end) TIMSK0 |= _BV(OCIE0A); //This enables the interrupt by changing a bit in a Register to 1 usingInterrupt = true; } // Do not call the interrupt function COMPA anymore else { TIMSK0 &= ~_BV(OCIE0A); //This enables the interrupt by changing a bit in a Register to 0 usingInterrupt = false; } }