 
 void updateLed1()
 {
-  if (digitalRead(sensorPin1) == HIGH) 
-  {
-    digitalWrite(ledPin1, HIGH);
-  } 
-  else 
-  {
-    digitalWrite(ledPin1, LOW);
-  }
+	if (digitalRead(sensorPin1) == HIGH) 
+		digitalWrite(ledPin1, HIGH);
+	else 
+		digitalWrite(ledPin1, LOW);
 }
 
 void updateLed2()
 {
-  if (digitalRead(sensorPin2) == HIGH) 
-  {
-    digitalWrite(ledPin2, HIGH);
-  } 
-  else 
-  {
-    digitalWrite(ledPin2, LOW);
-  }
+	if (digitalRead(sensorPin2) == HIGH) 
+		digitalWrite(ledPin2, HIGH);
+	else 
+		digitalWrite(ledPin2, LOW);
 }
 

#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14

const byte ledPin1 = 13;
const byte ledPin2 = 14;
const byte sensorPin1 = 2;
const byte sensorPin2 = 3;

void setup()
{

	SPI.setMOSI(SDCARD_MOSI_PIN);
	SPI.setSCK(SDCARD_SCK_PIN);
	if (!(SD.begin(SDCARD_CS_PIN))) {
		// stop here, but print a message repetitively
		while (1) {
			Serial.println("Unable to access the SD card");
			delay(500);
		}
	}
	dc1.amplitude(1.);
	dc2.amplitude(1.);

	// Start playback
	digitalWrite(syncPin, HIGH);
}

void loop()
{
	if (play)
		playFile(tounes[currentSong]);
}

void playFile(const char *filename)
{
	digitalWrite(syncPin, LOW);
	play = 0;
	
	Serial.print("Playing file: ");
	Serial.println(filename);

	// Start playing the file.  This sketch continues to
	// run while the file plays.
	playWav1.play(filename);

	// A brief delay for the library read WAV info
	delay(5);

	// Simply wait for the file to finish playing.
	while (playWav1.isPlaying()) {
		rpmCounter1.update();
		rpmCounter2.update();
		updateLed1();
		updateLed2();
		// uncomment these lines if you audio shield
		// has the optional volume pot soldered
		float vol = analogRead(15);
		vol = vol / 1024;
		sgtl5000_1.volume(vol);
	}

	// Increment next song
	currentSong++;
	if (currentSong >= nbTounes)
		currentSong = 0;

	// Set play flag to true for next song
	digitalWrite(syncPin, HIGH);
}

void playTrigger()
{		
	play = 1;
}

void onRpm1(float val)
