 
     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);

char pass[] = "xxx";       // your network password

WiFiUDP Udp;                                // A UDP instance to let us send and receive packets over UDP
const IPAddress outIp(192,168,1,51);        // remote IP of your computer
const unsigned int outPort = 8000;          // remote port to receive OSC
const unsigned int localPort = 8888;        // local port to listen for OSC packets (actually not used for sending)



    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("");
	
	pinMode(D5, INPUT);
	
	

}

