Skip to main content

Timers are the hardware in the processor used to count and time events. Use this tag for questions about the hardware timers.

The Arduino processor chips have a number of timers/counters. Basically they are hardware that count things, however if they count pulses from the system clock (which runs at a known speed) they can also be used to time things.

Timers have an input which can be an external signal, or the system clock. If counting an external signal they can be used to count something like how many pulses are detected on a pin. If counting the system clock they can be used as an elapsed-time timer.

The input can go through a prescaler which divides down the input (eg. by 64). This lets you have the counter "tick over" more slowly than it otherwise might.

Timers are usually described as 8-bit, 10-bit, 16-bit and so on. The number of bits indicates the maximum the counter/timer can count to before overflowing. For example, an 8-bit counter can count to 256.

Timers can be configured to raise interrupts on various events, for example:

  • Timer overflow
  • A certain count has been reached

The timers can also be used to generate pulses. PWM (pulse-width-modulation) can be configured to have a certain frequency, and a certain duty cycle, depending on the way the timer registers are set.