   pinMode(pinLa,OUTPUT);
   pinMode(pinLb,OUTPUT);
   pidL.SetMode(AUTOMATIC);
-  pidL.SetSampleTime(100);
+  pidL.SetSampleTime(40);
 }
 
 void initrightwheel()

PID pidR(&inputR,&outputR,&SetpointR,Kp,Ki,Kd,DIRECT);

void setup() {
  pinMode(INTA,INPUT);
  pinMode(INTB,INPUT);

  initleftwheel();
  initrightwheel();
  
  attachInterrupt(0,wheelspeedL,CHANGE);
  attachInterrupt(1,wheelspeedR,CHANGE);

  Serial.begin(9600);
}

void loop() {
  char key[2];
  if(Serial.available()>0)
  {   
      Serial.readBytes(key,sizeof(key)); 
  }
  switch(key[0])
  {
    case 'L':

  pinMode(pinRa,OUTPUT);
  pinMode(pinRb,OUTPUT);
  pidR.SetMode(AUTOMATIC);
  pidR.SetSampleTime(40);
}

void wheelspeedL()
