0

Adafruit Audio FX WAV/OGG trigered
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Audio FX WAV/OGG trigered

by rjmucc on Mon Aug 06, 2018 1:24 pm

Hi. I am only 14 years old and am getting started in coding. I have already done a couple of projects. I am working on one now and it includes the adafruit audio fx soundboard. I was wondering if i could activate the sounds without buttons or serial port. Just activate the soundboard with arduino. I have tried a code out. It hasn't worked and wondering if you can point some things out that I'm missing. Again, this code hasn't worked and probably won't cause this isn't right. Here's the code...


Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_Soundboard.h>

#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() {


   
}


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);
}
Last edited by adafruit_support_carter on Mon Aug 06, 2018 1:28 pm, edited 1 time in total.
Reason: added [code] tags

rjmucc
 
Posts: 4
Joined: Mon Aug 06, 2018 1:06 pm

Re: Adafruit Audio FX WAV/OGG trigered

by adafruit_support_carter on Mon Aug 06, 2018 1:29 pm

Generally seems OK. However, you don't have a call to your activateSound function.

adafruit_support_carter
 
Posts: 12958
Joined: Tue Nov 29, 2016 2:45 pm

Re: Adafruit Audio FX WAV/OGG trigered

by rjmucc on Mon Aug 06, 2018 1:35 pm

The thing is that the project were doing is that we want to activate it without button or serial. Plus this is a modified code that i had pulled off the web. I dont want to make this too hard and have someone stress out cause of the specifications i have. But, yes i agree i do not have an activate sound code i have just realized. But i have tried with a call to activate sound.

rjmucc
 
Posts: 4
Joined: Mon Aug 06, 2018 1:06 pm

Re: Adafruit Audio FX WAV/OGG trigered

by adafruit_support_carter on Wed Aug 08, 2018 12:15 pm

Hardware-wise, it sounds like you are trying to do something similar to what is being done here:
https://learn.adafruit.com/screaming-ca ... he-circuit
The Trinket M0's digital out 2 is connected to the Sound Board trigger 0. You would do something similar. Then, software-wise, it's just a matter of setting the digital pin LOW to do the same thing as what a button press would do. You can see that being done in the CircuitPython code:
https://learn.adafruit.com/screaming-ca ... uldron-4-2
with this line:
Code: Select all | TOGGLE FULL SIZE
        aFXPin.value = False

In Arduino, that would be digitalWrite(pin, LOW).

adafruit_support_carter
 
Posts: 12958
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.