   pinMode(2,INPUT_PULLUP);
   pinMode(3,INPUT_PULLUP);
   Serial1.setTimeout(10);
+  Serial.setTimeout(10);
 
   //while (!Serial1) {
     //; // wait for serial port to connect. Needed for Leonardo only

// Button values are reversed because of pullup resistors
int pedalUp = 1;
int pedalDown = 0;
boolean rightPedalWasDown = false;

void setup() {  

      yCarryOver -= y;
    }
    
    // Todo: turn left and right click logic into a single reusable function that takes previous state and pedal read function pointer
    if(!leftPedalWasDown){
      if(readLeftPedal() == pedalDown){
        delay(250);
      
        if(readLeftPedal() == pedalUp){
          logger("Left button click.");
          // A quick release is interpreted as a click
          Mouse.click();
        } else {
          logger("Left button hold.");
          Mouse.press();
          leftPedalWasDown = true;
        }  
      }
      
    } else {
      if(readLeftPedal() == pedalUp) {
        logger("Left button release");
        Mouse.release();
        leftPedalWasDown = false;
      }
    }
    
    if(!rightPedalWasDown){
      if(readRightPedal() == pedalDown){
        delay(300);
      
        if(readRightPedal() == pedalUp){
          logger("Right button click.");
          // A quick release is interpreted as a click
          Mouse.click(MOUSE_RIGHT);
        } else {
          logger("Right button hold.");
          Mouse.press(MOUSE_RIGHT);
          rightPedalWasDown = true;
        }  
      }
      
    } else {
      if(readRightPedal() == pedalUp) {
        logger("Rigth button release.");
        Mouse.release(MOUSE_RIGHT);
        rightPedalWasDown = false;
      }
    }
   
    
    if (Serial1.find("c")) {
      // We've received the start of a control code
