   //turn the PID on
   myPID.SetMode(AUTOMATIC);
   myPID.SetOutputLimits(-50, 50);
+  
+  //*****************************************************
+  pinMode(pinA, INPUT);
+  digitalWrite(pinA, HIGH);
+  attachInterrupt(0, int0, CHANGE);
+  //PCintPort::attachInterrupt(pinA, &int0, CHANGE);
+  pinMode(pinB, INPUT);
+  digitalWrite(pinB, HIGH);
+  attachInterrupt(1, int1, CHANGE);
+  //PCintPort::attachInterrupt(pinB, &int1, CHANGE);
+  
+  // Pin used to get absolute position
+  pinMode(pinReset, INPUT);
+  digitalWrite(pinReset, HIGH);
+  PCintPort::attachInterrupt(pinReset, &reset, CHANGE);
+  
 }
 
 void serialEvent() {

//Specify the links and initial tuning parameters (Kp, Ki, Kd)
PID myPID(&Input, &Output, &Setpoint, 1, 1, 1, DIRECT);

void setup()
{
  // Initialize software serial communication with Sabertooth 

// It is as well derived from HBridgePWM.ino from robokite project
// http://code.google.com/p/robokite/source/browse/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
// Parts of code taken from http://playground.arduino.cc/Main/RotaryEncoders J.Carter(of Earth)

#define NO_PORTB_PINCHANGES // PortB used for mySofwareSerial
#include <mySoftwareSerial.h>
#include <SabertoothSimplified.h>
#include <TinyGPS++.h>
#include <PID_v1.h>
#include <PinChangeInt.h>


mySoftwareSerial SWSerial(NOT_A_PIN, 8); // RX on no pin (unused), TX on pin 11 (to S1).
SabertoothSimplified ST(SWSerial); // Use SWSerial as the serial port.

const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
