    
                 Error = curangle-angle;
  }
+ 
+ void receiveEvent(int howMany)
+  {
+    
+    if(Wire.available()>0)
+    {
+  x = Wire.read();
+  if(x == 40) 
+  digitalWrite(13, HIGH);
+  else digitalWrite(13, LOW);
+ angle = (double) x;
+    }  
+}
+
+ 
+ 
 void loop() 
-{ 
-	   
+{               
+   
                  Errorcalc();
                 if (abs(Error) <2.2){ // prevent integral 'windup'
                 Integral = Integral + Error; // accumulate the error integral

#include <Wire.h> 
double potcurval;    // variable to read the value from the analog pin 
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;
 
 String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

 void backward()
 {

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