Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple Arduino trigger of the Adafruit Audio FX Sound Board
// A simple trigger for the Adafruit Audio FX Sound Board
// For complete info on the sound board, see https://learn.adafruit.com/adafruit-audio-fx-sound-board/overview
/*
This is a simple test of a direct trigger of the Audio FX Sounds Board from an Arduino.
For my test, I used an Arduino Pro Mini running at 3.3v & 8mHz. Digital pin #4 of the Arduino
was connected to trigger pin #0 of the Sound Board, and I tied them to a common ground. I powered
Sound Board via a USB external battery for the initial tests, and the Arduino via the FTDI cable.
For later tests, I powered the Sound Board via the Arduino's VCC (3v) pin directly.
*/
#define PIN 4
#define LED 13 // Most Arduinos have an LED on pin 13
#define BUTTON 2 // put a simple button on pin 2 to enable/disable sound playback
void setup() {
pinMode(LED, OUTPUT); // Make the LED pin active
pinMode(BUTTON, INPUT_PULLUP);
setupSound(PIN);
}
void loop() {
if (digitalRead(BUTTON) == HIGH) {
delay(500);
activateSound(PIN);
delay(500);
}
}
void setupSound(int pin) {
pinMode(pin, OUTPUT);
digitalWrite(pin, HIGH); // Set the pin high as the default state
}
void activateSound(int pin) {
digitalWrite(LED, HIGH);
digitalWrite(pin, LOW); // bring the pin low to begin the activation
/*
According to the documentation, the Audio FX board needs 50ms to trigger. However,
I've found that coming from my 3.3v Arduino Pro, it needs 100ms to get the trigger
the going
*/
delay(100); // hold the pin low long enough to trigger the board; may need to be longer for consistent triggering
digitalWrite(pin, HIGH); // bring the pin high again to end the activation
digitalWrite(LED, LOW);
}

A simple trigger for the Adafruit Audio FX Sound Board

For complete info on the sound board, see https://learn.adafruit.com/adafruit-audio-fx-sound-board/overview

What I'm Doing Here

This is a simple test of a direct trigger of the Audio FX Sounds Board from an Arduino.

For my test, I used an Arduino Pro Mini running at 3.3v & 8mHz. Digital pin #4 of the Arduino was connected to trigger pin #0 of the Sound Board, and I tied them to a common ground. I powered Sound Board via a USB external battery for the initial tests, and the Arduino via the FTDI cable. For later tests, I powered the Sound Board via the Arduino's VCC (3v) pin directly.

Things to Note

The Audio FX board pins are trigger when connected to ground (they're set up this way so they'll work with simple normally open push buttons connected directly to the board's ground). This has a couple of implications:

  • To trigger a given pin on the Audio FX board, we need to bring the Arduino pin tited to it to LOW, then back to HIGH.
  • I've found that adding a delay of 100ms is after setting to LOW is is long enough for the Audio FX board to register the trigger event with my 3v3 Arduino. The documentation stats that the board should be able to detect the trigger in 50ms. Not sure if the discrepency is due to the slower clock speed (8mHz) on the Arduino. I'll try it with a 5v Arduino running at 16mHz to see if that has any effect.
    • It turns out even 100ms might not be enough. In another project that I've got going, I had to hold the pin LOW for 250ms to consistently get a trigger to fire.
  • When the board is first powered on, the Arduino pins get set to OUTPUT mode. When that happens, the pins are triggered, causing the sounds to play. I'm not sure of the best way to suppress this, but it bears investigating. UPDATE: I don't think this is actually the case. I added a button to trigger the beginning of the playback. There is no trigger until that button is pressed. Yay!
  • Don't forget to tie the sound board and Arduino's ground together! :)
@gerfderp

This comment has been minimized.

Copy link

gerfderp commented Jun 11, 2017

Thank you for this. It saved me hours of trial and error.

@prichardson

This comment has been minimized.

Copy link

prichardson commented Sep 25, 2017

ty...

If using a mega try pin 52 instead.

@gizmoprops

This comment has been minimized.

Copy link

gizmoprops commented Jun 13, 2018

Thank you so much. The last bullet about the ground to the Arduino was the key for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.