I found another way that does not consume so many pins. The Adafruit FX Module also has the option of a serial connections.
You need to ground the ‘UG’ pin on the module. Connected the TX pins to the RX pins to the Module, then provide 5V and GND as normal.
So a total of 2 pins connected to the core. TX and in my case A0 for reset.
So in my code I have this in setup()
Serial.begin(9600);
Serial1.begin(9600);
(Serial is for debugging and Serial1 is the link to the Module)
And to trigger a ‘track’ you have to send the file name without the dot then directly afterwards send a new line.
{Serial1.println("PT06RAND0OGG\n");Serial1.println("");
If the file name has less than 8 characters in the name, you need to offset that with spaces.
And to restart on boot and trigger a remote reset on the module I did this.
pinMode(REBOOT, INPUT);
digitalWrite(REBOOT, HIGH);
Then added this in the loop().
TriggerReset(REBOOT);
Then created a fuction for TriggerReset.
void TriggerReset(int pin)
{
digitalWrite(pin, LOW);
pinMode(pin, OUTPUT);
delay(150);
pinMode(pin, MODE);
digitalWrite(pin, HIGH);
}
So on boot it will reset the module and I can also reboot the module via a Spark.function()
And example of the remote reboot.
else if (command == "reset") {TriggerReset(REBOOT); Serial.println("REBOOT - ADAFRUIT_FX BOARD");return 25;}
You can do other things like pass the filename directly to the module via a Spark.function.
Here’s an example of it in use.
https://goo.gl/photos/WfYzENymUWk1j6K87
Some info about that hardware in the video.
Spark core /w a Shield Shield. An Adafruit FX Module. 36 Neopixels. And a inductive speaker that has been recessed into the body of the sign. This is all controlled by SmartThings. There are about 36 sound files all teamed up with a visual effect.
One of the behaviors (And my favorite) When I get home, SmartThings detects my presence tag on my keys. It opens the garage door, Unlocks the door. then the house numbers turn on and plays the theme song to air wolf.
If a random person come up to the door (trips a motion sensor) then the Star Trek tricorder effect plays with a slow rainbow effect.
Heh. Halloween was a blast last year. In combination of the lights (The sign itself and all the lights in the house) and sounds. It was awesome.
At anyrate, I hope the info above helps anyone out.