Sfoglia il codice sorgente

test sketch

playing audio files while printing LDR values
Etienne Landon 8 anni fa
parent
commit
fdafadca39
1 ha cambiato i file con 34 aggiunte e 41 eliminazioni
  1. 34 41
      I_Mihalache_AudioPlayer.ino

+ 34 - 41
I_Mihalache_AudioPlayer.ino

@@ -43,8 +43,8 @@ AudioControlSGTL5000     sgtl5000_1;     //xy=573,537
 
 void setup() {
   Serial.begin(9600);
-  DmxSimple.maxChannel(4);
-  DmxSimple.write(4, 250);
+//  DmxSimple.maxChannel(4);
+//  DmxSimple.write(4, 250);
   pinMode(16, INPUT);
   pinMode(20,INPUT);
   // Audio connections require memory to work.  For more
@@ -67,29 +67,31 @@ void setup() {
       delay(500);
     }
   }
+  delay(2000);
 }
 //
-//void playFile(const char *filename)
-//{
-//  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()) {
-//    // uncomment these lines if you audio shield
-//    // has the optional volume pot soldered
-//    //float vol = analogRead(15);
-//    //vol = vol / 1024;
-//    // sgtl5000_1.volume(vol);
-//  }
-//}
+void playFile(const char *filename)
+{
+  Serial.print("Playing file: ");
+  Serial.println(filename);
+
+  // Start playing the file.  This sketch continues to
+  // run while the file plays.
+  playSdWav1.play(filename);
+
+  // A brief delay for the library read WAV info
+  delay(5);
+
+  // Simply wait for the file to finish playing.
+  while (playSdWav1.isPlaying()) {
+    printLDR();
+    // uncomment these lines if you audio shield
+    // has the optional volume pot soldered
+    //float vol = analogRead(15);
+    //vol = vol / 1024;
+    // sgtl5000_1.volume(vol);
+  }
+}
 
 void printLDR(){
   Serial.print(analogRead(A3));
@@ -103,25 +105,16 @@ void printLDR(){
 }
 
 void loop() {
-  int brightness;
-  /* Simple loop to ramp up brightness */
-  for (brightness = 0; brightness <= 255; brightness++) {
-    
-    /* Update DMX channel 1 to new brightness */
-    DmxSimple.write(1, brightness);
-    printLDR();
-    /* Small delay to slow down the ramping */
-    delay(10);
-  }
+
   
   delay(100);
-//  playFile("SDTEST1.WAV");  // filenames are always uppercase 8.3 format
-//  delay(500);
-//  playFile("SDTEST2.WAV");
-//  delay(500);
-//  playFile("SDTEST3.WAV");
-//  delay(500);
-//  playFile("SDTEST4.WAV");
-//  delay(1500);
+  playFile("SDTEST1.WAV");  // filenames are always uppercase 8.3 format
+  delay(500);
+  playFile("SDTEST2.WAV");
+  delay(500);
+  playFile("SDTEST3.WAV");
+  delay(500);
+  playFile("SDTEST4.WAV");
+  delay(1500);
 }