 
 
 unsigned long lastmicros = micros();
+long laststepperpos = 0, lastencoder0Pos = 0;
 int printcounter = 0;
 
 void loop(){ 
+  // PID loop
   pidInput = encoder0Pos;
   if (abs(pidInput-pidSetpoint) < CLOSE_ENOUGH) {
     goalSpeed = 0;

    goalSpeed = pidOutput;
  }
    
  
  unsigned long dt = micros() - lastmicros;
  lastmicros = micros();
  
  updateSpeed(dt);
  
  
  // check for incoming messages 
  etherOSC.listen();
  
  
  if (printcounter==0) {
    sendOscStatus();
  }
  if (printcounter++ > 100) printcounter = 0;
  

  Timer1.pwm(PULSEPIN, 0);
  Timer1.start();
  
  Timer1.attachInterrupt(countSteps);
}


