       index = i;
     }
   }
-  noteOn(0, index+octave*12, 64);
-  MIDIUSB.flush();
+  
+//  noteOn(0, index+octave*12, 64);
+//  MIDIUSB.flush();
+  
+  if(continuousNote == false){
+    Serial.println("note off");
+    noteOff(0, index+octave*12, 64);
+    MIDIUSB.flush();
+  }
+  
   delay(t);
-  
-  noteOff(0, index+octave*12, 64);
-  MIDIUSB.flush();
+  if(sameColorCount == 0){
+    noteOn(0, index+octave*12, 64);
+    MIDIUSB.flush();
+  }
 }
 
 int octave = 4;
 void color_to_note_normal(int c) {
-  Serial.print("normal note");
   switch(c){
   case 0:
-    playNote("C", octave, 650);
+    playNote("C", octave, 400);
     break;
   case 1:
-    playNote("D", octave, 500);
+    playNote("D", octave, 400);
     break;
   case 2:
-    playNote("E", octave, 500);
+    playNote("E", octave, 400);
     break;
   case 3: 
-    playNote("F", octave, 500);
+    playNote("F", octave, 400);
     break;
   case 4:
-    playNote("G", octave, 500);
+    playNote("G", octave, 400);
     break;
   case 5:
-    playNote("A", octave, 500);
+    playNote("A", octave, 400);
     break;
   case 6:
-    playNote("B", octave, 500);   
-    break;
+    playNote("B", octave, 400);   
+    break;
+  default:
+    Serial.println("note off");
+    noteOff(0, index+octave*12, 64);
+    MIDIUSB.flush();
   }
 }
 

  switch(c)
  {
  case 0:
    playNote("B", ,octave - 1 300);
    break;
  case 1:
    playNote("C#", octave, 300);
    break;
  case 2:
    playNote("D#", octave, 300);
    break;
  case 3: 
    playNote("E", octave, 300);
    break;
  case 4:
    playNote("F#", octave, 300);
    break;
  case 5:
    playNote("G#", octave, 300);
    break;
  case 6:
    playNote("A#", octave, 300);   
    break;
  }
}

  }
}

int color = 99;
int prevColor = 99;
bool continuousNote = true;
int sameColorCount = 0;

void loop() {
  color = get_colors();
  Serial.println(color);
  if(prevColor == color){
    continuousNote = true;
    sameColorCount += 1;
  }
  else{
    continuousNote = false;
    sameColorCount = 0;
  }
  prevColor = color; 

  buttonStateSharp = digitalRead(buttonPinSharp);
  buttonStateFlat = digitalRead(buttonPinFlat);
  if (buttonStateSharp == LOW) {
    // turn LED on:
    color_to_note_flat(color);
  } 
  else if(buttonStateFlat == LOW) {
    color_to_note_sharp(color);
  }
  else{
    // turn LED off:
    color_to_note_normal(color);
  }
  delay(400);
}

int get_colors(){
