For Leonardo Users:

Leonardo Timer DIfferences

Customer and forum member ytoff57 has successfully ported this code to the Leonardo. One difference between the Leonardo and the Arduino is the timers, so the timer interrupt code does not work on that platform. His has tested the following modifications based on the TimerOne library:
Download: file
#include <TimerOne.h>
//...
void setup()
{
  //...
  Timer1.initialize(15000);
  Timer1.attachInterrupt(TimerInterrupt);
}
//..
void TimerInterrupt() 
{
  if (opState == OFF)
  {
    digitalWrite(RelayPin, LOW);  // make sure relay is off
  }
  else
  {
    DriveOutput();
  }
}
This guide was first published on Jun 10, 2013. It was last updated on Jun 10, 2013. This page (For Leonardo Users:) was last updated on Dec 08, 2019.