 // This file used SoftwareSerial example (Copyright (c) 2012 Dimension Engineering LLC) for Sabertooth http://www.dimensionengineering.com/software/SabertoothSimplifiedArduinoLibrary/html/index.html
 // See license.txt in the Sabertooth arduino library for license details.
 // It is as well derived from HBridgePWM.ino from robokite project
-// http://code.google.com/p/robokite/source/browse/HBridgePWM/HBridgePWM.ino
+// https://github.com/baptistelabat/robokite/blob/master/HBridgePWM/HBridgePWM.ino
 // The selector 1 3 5 6 have to be on on.
 //
 // Using example in http://code.google.com/p/arduino-pinchangeint/wiki/Usage

  if ( micros() - int0time < threshold )
    return;
  int0history = int0signal;
  int0signal = bitRead(PIND,pinA);
  if ( int0history==int0signal )
    return;
  int0time = micros();

double linearResolution = 0.005; //Resolution of the linear encoder (in meters)
double linearRange = 0.5; //Range of the sensor to normalize data (+/- linearRange/2)

double pi = 3.1415;
double potentiometerRangeDeg = 300; 
double potentiometerMaxRange = potentiometerRangeDeg * pi/180;
double potentiometerUsedRange = pi;
double potentiometerDistance = 0.05; //Distance from rotation axis to lever arm
//*********************************************************************************************

void setup()
{
  // Initialize software serial communication with Sabertooth 
  SWSerial.begin(9600);
  
  // Initialize serial communications at 9600 bps:
  Serial.begin(19200);
  
  // Initialize input and setpoint
  Input1 = 0;
  Input2 = 0;
  InputRoll = 0;
  Setpoint1 = 0;
  Setpoint2 = 0;
  SetpointRoll = 0;
  
  //turn the PID on
  myPID1.SetMode(AUTOMATIC);
  myPID2.SetMode(AUTOMATIC);
  myPIDRoll.SetMode(AUTOMATIC);
  myPID1.SetOutputLimits(-1, 1);
  myPID2.SetOutputLimits(-1, 1);
  myPIDRoll.SetOutputLimits(-1, 1);
  
  //*****************************************************
  pinMode(pinA, INPUT);
