 #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()
  {


}

void receiveEvent(int howMany)
{
  int x = Wire.read();
  angle = (double) x;
  Serial.print("got: ");
  Serial.println(angle);
  if(angle == 40) digitalWrite(13, HIGH);
  else digitalWrite(13, LOW);
}

  Serial.begin(9600);
  pinMode(11,OUTPUT);
  pinMode(13, OUTPUT);
  Wire.begin(1);
  Wire.onReceive(receiveEvent);
} 
