     halfSteps--;
 }
 
+// Taken from http://playground.arduino.cc/Main/RotaryEncoders J.Carter(of Earth)
 void int1()
 {
   if ( micros() - int1time < threshold )

PID myPID2(&Input2, &Output2, &Setpoint2, 1, 0, 0, DIRECT);

// Define global variables to deal with encoder interrupt
volatile unsigned long threshold = 1000;// 'threshold' is the De-bounce Adjustment factor for the Rotary Encoder. halfSteps
volatile unsigned long int0time = 0;
volatile unsigned long int1time = 0;
volatile uint8_t int0signal = 0;

// Hardware specific parameters
// Potentiometer
#define POT_RANGE_DEG      300 // 300 is the value for standard potentiometer
#define POT_USED_RANGE_DEG  60 // To normalize and saturate rotation
#define POT_OFFSET        0.05 // Distance from rotation axis to lever arm (in m)
#define NEUTRAL_ANGLE_DEG  225 // Zero of the potentiometer
// Linear encoder
#define LINEAR_RESOLUTION 0.005// Resolution of the linear encoder
#define LINEAR_USED_RANGE 0.05 // To normalize and saturate translation motion

void setup()
{
