Adafruit is open and shipping! Let's build back better, together!
0

Adafruit Sound Board 2Meg version - using UART
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Sound Board 2Meg version - using UART

by Chris_Cooper on Sat Nov 21, 2020 11:37 am

Hi All,

I have recently installed an Adafruit 2Meg Sound FX Board into a project, which I am addressing via UART and not GPIO. It works, but only with spurious problems, especially when trying to get it started.

For example, please see the function below, which is what I have to do to get the unit to play a track. You will see at the beginning of the function, I use the "sfx.listfiles" command twice, which if I do not do this, it doesn't work. The serial monitor displays an empty file list twice, however, it then more often than not, plays the first track listed in the next command "sfx.playTrack" and if that fails, it plays the second track.

I thought its was slow to start, but I have tried delays, this doesn't make a difference.

Minimal pins connected, Vcc 5V, GND, TX, RX, RST and the UG to GND.

Any ideas?

Many thanks.

Regards,

Christopher

Code: Select all | TOGGLE FULL SIZE
void testSound() {

   // Adafruit Soundboard.

   if (!sfx.reset()) {
      matrix.print("SFX error...");
      matrix.show();
      while (1);
   }

   matrix.print("SFX OK!");
   matrix.show();

   // List files.

   uint8_t files = sfx.listFiles();

   Serial.println("File Listing");
   Serial.println("========================");
   Serial.println();
   Serial.print("Found "); Serial.print(files); Serial.println(" Files");
   for (uint8_t f = 0; f < files; f++) {
      Serial.print(f);
      Serial.print("\tname: "); Serial.print(sfx.fileName(f));
      Serial.print("\tsize: "); Serial.println(sfx.fileSize(f));
   }
   Serial.println("========================");

   sfx.stop();

   files = sfx.listFiles();

   Serial.println("File Listing");
   Serial.println("========================");
   Serial.println();
   Serial.print("Found "); Serial.print(files); Serial.println(" Files");
   for (uint8_t f = 0; f < files; f++) {
      Serial.print(f);
      Serial.print("\tname: "); Serial.print(sfx.fileName(f));
      Serial.print("\tsize: "); Serial.println(sfx.fileSize(f));
   }
   Serial.println("========================");

   // Test track to play.

   delay(1000);

   uint8_t n = 1;

   matrix.clear();
   matrix.setCursor(0, 0);
   matrix.print("Track #");
   matrix.show();
   delay(750);
   matrix.clear();
   matrix.setCursor(0, 0);
   matrix.print(n);
   matrix.show();
   delay(750);

   if (!sfx.playTrack((uint8_t)n)) {
      matrix.clear();
      matrix.setCursor(0, 0);
      matrix.print("Error.");
      matrix.show();

      n = 2;

      // If first track didnt play, play next track.

      matrix.clear();
      matrix.setCursor(0, 0);
      matrix.print("Track #");
      matrix.show();
      delay(750);
      matrix.clear();
      matrix.setCursor(0, 0);
      matrix.print(n);
      matrix.show();
      delay(750);

      if (!sfx.playTrack((uint8_t)n)) {
         matrix.clear();
         matrix.setCursor(0, 0);
         matrix.print("Error.");
         matrix.show();
      }

   }

   delay(750);

}  // Close function.

Chris_Cooper
 
Posts: 16
Joined: Sun Jun 07, 2020 11:05 am

Please be positive and constructive with your questions and comments.