 
     Serial.println("sending first note");
 	
-	sendNote(45, 120, -1);
-    
+	//sendNote(45, 120, -1);
+    bool isPlaying = 0;
+	while (1)
+	{
+	    int val = digitalRead(D5);
+		int analogVal = analogRead(A0);
+		
+		Serial.print("New value : ");
+		Serial.println(val);
+	    Serial.print("Analog : ");
+		Serial.println(analogVal);
+		if (isPlaying == 0)
+		{
+		    if(val != 1)
+		    {
+		        startNote(65, 80);
+				startNote(53, 120);
+				startNote(41, 120);
+	            isPlaying = 1;
+			}
+		}
+		else
+		{
+			if(val == 1)
+		    {
+		        stopNote(65);
+				stopNote(53);
+				stopNote(41);
+	            isPlaying = 0;
+			}
+  
+	    }
+		delay(5);
+	}
+	
     while(1){
 
     	  accel.getEvent(&event);


    delay(1000); //wait for I2C init
    /* Initialise the sensor */
    if(!accel.begin())
    {
        /* There was a problem detecting the ADXL345 ... check your connections */
        Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
        while(1);  //will cause watchdog time out
    }

    /* Set the range to whatever is appropriate for your project */
    accel.setRange(ADXL345_RANGE_16_G);
    // displaySetRange(ADXL345_RANGE_8_G);
    // displaySetRange(ADXL345_RANGE_4_G);
    // displaySetRange(ADXL345_RANGE_2_G);
  
    /* Display some basic information on this sensor */
    displaySensorDetails(&accel);
  
    /* Display additional settings (outside the scope of sensor_t) */
    displayDataRate(&accel);
    displayRange(&accel);
    Serial.println("");

}


	    sendOSCMessage(noteMsg, 0);
	}
}
void startNote(unsigned int note, unsigned int velocity)
{
    String prefix  =  "/vkb_midi/0/note/";
	String noteMsg = prefix + String(note);
	sendOSCMessage(noteMsg, velocity);

}
void stopNote(unsigned int note)
{
    String prefix  =  "/vkb_midi/0/note/";
	String noteMsg = prefix + String(note);
	sendOSCMessage(noteMsg, 0);

}
void sendCC(unsigned int nb, unsigned int value)
{
    String prefix = "/vkb_midi/0/cc/";
