Extending Arduino with Timer1

Making the basics better

Published
August 10, 2008
Reading Time
1 minute

Timer1 is an AVR and Arduino compatible software library for the ATmega168 microcontroller. It provides a user friendly interface for taking advantage of two commonly used features of an on-chip hardware timer:

  • pulse width modulated analog voltage
  • timer overflow interrupt handling.

Initially this library was built to address the fact that Arduino’s analogWrite() function does not provide a mechanism to change the period or frequency of any of the timers which drive hardware based pulse width modulation, but it has since grown to accommodate the interrupt handling features as they are related and just downright useful.

Some of the things we have used the library for on projects in house include:

  • CPU independent servo control
  • Frequency generation in the audible range (digital synthesis)
  • Integrated hardware / software PWM control for independently variable analog voltages on 12 pins simultaneously (4x RGB leds)

You can download the library and learn much more about the project by visiting our page on the Arduino Playground at: http://www.arduino.cc/playground/Code/Timer1

Jesse Tane