   Serial.begin(9600);
   pinMode(pedalPin1, INPUT);
   pinMode(pedalPin2, INPUT);
-  pinMode(ledPin1, OUTPUT);
+  pinMode(ledRedPin, OUTPUT);
+  pinMode(ledGreenPin, OUTPUT);
+  pinMode(ledBluePin, OUTPUT);
+  pinMode(modeButtonPin, INPUT);
   
 }
 

const int KEYCODE_A = 0x04;
const int KEYCODE_B = 0x05;


const int pedalPin1 = 2;
const int pedalPin2 = 3;
const int ledPin1 = 4;

int lastPedalEvent1 = 0;
int lastPedalEvent2 = 0;

int DBG_MODE = 0;


  int pedalEvent1 = digitalRead(pedalPin1);
  int pedalEvent2 = digitalRead(pedalPin2);

  int modeButtonEvent = digitalRead(modeButtonPin);
  
  
  if(lastModeEvent != modeButtonEvent) {
    if(modeButtonEvent == HIGH) {
      mode = (mode+1)%3;
      if(DBG_MODE) {
        Serial.print("mode:");
        Serial.println(mode);
      }
    switch(mode) {
      case MODE_EMACS:
        setColor(50, 0, 0);
      break;
      case MODE_INTELLIJ:
        setColor(0, 50, 0);
      break;
      case MODE_INTERNET:
        setColor(0, 0, 50);
      break;
    }
      delay(50);
    }
    lastModeEvent = modeButtonEvent;
  }
  
  if((lastPedalEvent1 == pedalEvent1) && (lastPedalEvent2 == pedalEvent2)) {
    return;
  }
  
  if((pedalEvent1 == HIGH) || (pedalEvent2 == HIGH)) {
    if(pedalEvent1 == HIGH) input(getLeftInput());
    if(pedalEvent2 == HIGH) input(getRightInput());
    lastPedalEvent1 = pedalEvent1;
    lastPedalEvent2 = pedalEvent2;
    setColor(50, 50, 0);
  } else {
    releaseKey();
    lastPedalEvent1 = pedalEvent1;
    lastPedalEvent2 = pedalEvent2;    
    setColor(0, 0, 0);
  }
}

void setColor(int red, int green, int blue)
{
  analogWrite(ledRedPin, red);
  analogWrite(ledGreenPin, green);
  analogWrite(ledBluePin, blue); 
}

int getLeftInput() {
  int keycode = LEFT_CTRL;
  switch(mode) {
    case MODE_EMACS:
      keycode = LEFT_CTRL;
    break;
    case MODE_INTELLIJ:
      keycode = KEYCODE_F8;
    break;
    case MODE_INTERNET:
      keycode = KEYCODE_SPACE;
    break;
  }
  return keycode;
}

int getRightInput() {
  int keycode = LEFT_ALT;
  switch(mode) {
    case MODE_EMACS:
      keycode = LEFT_ALT;
    break;
    case MODE_INTELLIJ:
      keycode = KEYCODE_F9;
    break;
    case MODE_INTERNET:
      keycode = KEYCODE_SPACE;
    break;
  }
  return keycode;
}

void input(int keycode) {
