How to use Timer1 (AT328Mega) to measure the time between rising edges of two input signals I'd like to use Timer1 to measure the time between rising edges of two input signals.  Specifically, use Tn to start the timer counter and IPCn to latch the elapsed time since the rising edge of the Tn input signal.  The goal is to measure the time between the rising edges of two input signals.   Is there a Timer1 library out there that alread does this?  Code suggestions welcomed.
It is not perfect for your simpler task, but here is a link to a sketch that I have used to record pulses, using the Timer1 Input Capture. 

In short setup the Interrupt

void initTimer(void) {

  // Input Capture setup
  // ICNC1: Enable Input Capture Noise Canceler
  // ICES1: =1 for trigger on rising edge
  // CS10: =1 set prescaler to 1x system clock (F_CPU)
  TCCR1A = 0;
  TCCR1B = (0&lt;&lt;ICNC1) | (0&lt;&lt;ICES1) | (1&lt;&lt;CS10);
  TCCR1C = 0;

  //catchFallingEdge(); // initialize to catch
  { TCCR1B &amp;= ~(1&lt;&lt;ICES1); TIFR1 |= (1&lt;&lt;ICF1); rising = 0; }

  // Interrupt setup
  // ICIE1: Input capture
  // TOIE1: Timer1 overflow
  TIFR1 = (1&lt;&lt;ICF1) | (1&lt;&lt;TOV1);        // clear pending
  TIMSK1 = (1&lt;&lt;ICIE1) | (1&lt;&lt;TOIE1); // and enable

  // Set up the Input Capture pin, ICP1, which corresponds to Arduino D8
  pinMode(8, INPUT);
  digitalWrite(8, 0);       // leave floating to count 60 Hz etc.
  //digitalWrite(8, 1);         // or enable the pullup
}


Then service it

ISR(TIMER1_CAPT_vect) {
  union twobyte {
    uint32_t word;
    uint8_t  byte[2];
  } timevalue;

  timevalue.byte[0] = ICR1L;        // grab captured timer value
  timevalue.byte[1] = ICR1H;        // grab captured timer value

  // watch for the other edge to catch the half-pulse width
  //rising ? catchFallingEdge() : catchRisingEdge();
  if (rising) {
    TCCR1B &amp;= ~(1&lt;&lt;ICES1);
    TIFR1 |= (1&lt;&lt;ICF1);
    rising = 0;
  }
  else {
    TCCR1B |= (1&lt;&lt;ICES1);
    TIFR1 |= (1&lt;&lt;ICF1);
    rising = 1;
  }
}