     analogWrite(D2, 0);
 }
  
-void motion(int lpwm, int rpwm, int llevel, int rlevel) {  
+void motion(double lpwm, double rpwm, int llevel, int rlevel) {  
     if (llevel==HIGH) {
       ldir=1; 
     } else {

  attachInterrupt(D5, lencode, CHANGE); // Setup Interrupt 
  attachInterrupt(D6, rencode, CHANGE); // Setup Interrupt 
  sei();                                // Enable interrupts  
  int currentTime = millis();
  int cloopTime = currentTime;
  os_timer_setfn(&myTimer, tic, NULL);
  os_timer_arm(&myTimer, period, true);   // timer in ms
  lPID.SetSampleTime(period);
  rPID.SetSampleTime(period); 
  tPID.SetSampleTime(period);  
  lPID.SetMode(AUTOMATIC);
  rPID.SetMode(AUTOMATIC);
  tPID.SetMode(AUTOMATIC);
  Serial.begin(115200);
  Serial.println("Ready");
}

      c=0;
    }
  }
  Serial.print(" lSet: ");
  Serial.print(lSet);
  Serial.print(" rSet: ");
  Serial.print(rSet);
  Serial.print(" lv:");
  Serial.print(lv);
  Serial.print(" rv:");
  Serial.print(rv);
  Serial.print(" lOut:"); 
  Serial.print(lOut*4);
  Serial.print(" rOut:");
  Serial.print(rOut*4);
  Serial.print(" lmc:");
  Serial.print(lmc);
  Serial.print(" rmc=");
  Serial.print(rmc);
  Serial.print(" tic#");
  Serial.print(ti);
  Serial.print(" lkp: ");
  Serial.print(lkp);
  Serial.print(" lki: ");
  Serial.print(lki);
  Serial.print(" lkd: ");
  Serial.println(lkd);
  rPID.Compute();
  lPID.Compute();
  motion(lOut,rOut,HIGH,HIGH);  
  delay(1000);
}

