Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Timer1cc Library:

Timer1 Capture/Compare

Timer 1 capture/compare library. This library is specifically for using the capture & compare feature of Timer1.

Current support:

  • ATmega328: Timer1 - mode 4 (CTC)
  • Adjustable prescaler
  • Adjustable rollover value with interrupt
  • Timer capture interrupt

Additional modes and compare output setting could be added to the library.

Usage:

This library has a built-in instance of the class. It is not intended to be instantiated. Use the built-in instance: Timer1. This example initializes Timer1 to rollover and interrupt once per second:

Timer1.initialize(TIMER_DIV256_62500HZ, 62500);
Timer1.attachRolloverInterrupt(myCallback);
Timer1.start();