I am using an Adafruit M4 Feather Express (PID# 3857) to serially control a 16MB 2x2W Soundboard (PID# 2217). I know that the ACT activity pin of the Sound Board goes LOW while a sound is being played. However, is this playTrack() activity blocking on the Feather end? Immediately after using the playTrack() function, I try to read the Sound Board ACT pin using one of the Feather's digital I/O pins to see if it reads LOW (so I can queue another action) but either the Feather continues reading HIGH the entire time or the Feather isn't able to read the pin at the time. At least that's what I'm guessing according the Serial console. Measuring the I/O pin in question using a multimeter does show the voltage physically dips down to ~0V from ~3.3V while a sound is being played.
Below is the code I've whipped up for testing this. Basically the idea was for the Serial console to output an upward count from 0 as soon as it detects the pin goes LOW while the sound is still actively playing. The sound loops as expected, and the physical voltage reading is what is expected, but the count never begins. It just continues printing the "loop start" statement. Something could be wrong with my code. I wouldn't be too shocked if that was the case. Any help is appreciated! Thanks!
Code: Select all
#include "Adafruit_Soundboard.h"
const int SFX_RST = 4;
const int soundboardActive = 11; // GPIO pin to read whether soundboard is currently playing an audio file. LOW when file being played.
Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial1, NULL, SFX_RST);
int x = 0;
void setup() {
Serial1.begin(9600);
pinMode(soundboardActive, INPUT_PULLUP);
}
void loop() {
Serial.println("loop start");
char soundToPlayChar[21];
String soundToPlayString = "10000000OGG";
soundToPlayString.toCharArray(soundToPlayChar, 20);
sfx.playTrack(soundToPlayChar);
//delay(100);
while(digitalRead(soundboardActive) == LOW){
Serial.println(x);
x = x + 1;
}
x = 0;
}