 
 EthernetUDP UDP;
 OscUDP etherOSC;  
-
-// message serial numbers to check for missing ones
-int messageNumber = 0;
 
 int MSEC_PER_STATUS = 50; // millseconds between sending status messages
 

// ENCODER HANDLERS -----------------------------



void doEncoderA(){

  // look for a low-to-high on channel A
  if (digitalRead(encoder0PinA) == HIGH) { 
    // check channel B to see which way encoder is turning
    if (digitalRead(encoder0PinB) == LOW) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  else   // must be a high-to-low edge on channel A                                       
  { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(encoder0PinB) == HIGH) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
  
  // mark Z
  int zeropin = digitalRead(encoder0PinZ);
  if (encoder0ZeroState == 0 && zeropin == 1) {
    encoder0Zero = encoder0Pos;
  }
  encoder0ZeroState = zeropin;
}

void doEncoderB(){

  // look for a low-to-high on channel B
  if (digitalRead(encoder0PinB) == HIGH) {   
   // check channel A to see which way encoder is turning
    if (digitalRead(encoder0PinA) == HIGH) {  
      encoder0Pos = encoder0Pos + 1;         // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;         // CCW
    }
  }
  // Look for a high-to-low on channel B
  else { 
    // check channel B to see which way encoder is turning  
    if (digitalRead(encoder0PinA) == LOW) {   
      encoder0Pos = encoder0Pos + 1;          // CW
    } 
    else {
      encoder0Pos = encoder0Pos - 1;          // CCW
    }
  }
}







void oscGo(OscMessage &m) {
  // /go/motor0pos,motor1pos,motor2pos,motor3pos long ints
  if (state != OK) return; 
  
  double value = m.getFloat(MOTOR_ID);
  pidSetpoint = value;
