 #include <Wire.h> 
-double potcurval;    // variable to read the value from the analog pin 
-int angel; //Integer value of angle
+volatile double potcurval;    // variable to read the value from the analog pin 
+volatile int angel; //Integer value of angle
  double angle =0;
-
- double curangle,kP=30.00,kI=0,kD=0,Last=0;
- double P=0,I=0,D=0,Drive,Error=0,Integral=0;
+volatile int x;
+ volatile double curangle,kP=30.00,kI=0,kD=0,Last=0;
+ volatile double P=0,I=0,D=0,Drive,Error=0,Integral=0;
  
- String inputString = "";         // a string to hold incoming data
-boolean stringComplete = false;  // whether the string is complete
 
  void backward()
  {

   
                Error = curangle-angle;
 }
void loop() 
{ 
	   
                 Errorcalc();
                if (abs(Error) <2.2){ // prevent integral 'windup'
                Integral = Integral + Error; // accumulate the error integral


}

