You have other options that could give you the effect you want. You need a very simple version of “multi-tasking” to do this, trigger the sound, and animate the CPU. This is because you’ll probably want to read the ADC on each pass through the Arduino loop(). You’d what to use a non-blocking method, such as a millis() based counter (see for an example of code that implements such a timer, and for some code that uses it). This code makes liberal use of delay(), which basically suspends the execution of the microcontroller for a period of time (in other words, delay() blocks the CPU). If you were going to use my code above to try this, you’d have to make some changes. Depending on the audio track you’re workin with, this might produce an interesting effect if you take the read values and use them to drive the LED pin’s PWM output. You can then use that to read the gain on the output sound. You don’t have any way to sync the components of the sound to this board directly, but you could feed it’s line level output on the R/L pins to an ADC or two (one per channel if it’s stereo, or either channel into a single ADC if it’s mono). The Sound FX Board may not be exactly what you want, though I think you could get what you’re looking for (sort of). Don't forget to tie the sound board and Arduino's ground together! ah I think I see.There is no trigger until that button is pressed. I added a button to trigger the beginning of the playback. UPDATE: I don't think this is actually the case. I'm not sure of the best way to suppress this, but it bears investigating. When that happens, the pins are triggered, causing the sounds to play. When the board is first powered on, the Arduino pins get set to OUTPUT mode.In another project that I've got going, I had to hold the pin LOW for 250ms to consistently get a trigger to fire. It turns out even 100ms might not be enough.I'll try it with a 5v Arduino running at 16mHz to see if that has any effect. Not sure if the discrepency is due to the slower clock speed (8mHz) on the Arduino. The documentation stats that the board should be able to detect the trigger in 50ms. I've found that adding a delay of 100ms after setting to LOW is long enough for the Audio FX board to register the trigger event with my 3v3 Arduino.To trigger a given pin on the Audio FX board, we need to bring the Arduino pin tied to it to LOW, then back to HIGH.The Audio FX board pins are triggered 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). The Sound Board via a USB external battery for the initial tests, and the Arduino via the FTDI cable.įor later tests, I powered the Sound Board via the Arduino's VCC (3v) pin directly. I've found that coming from my 3.3v Arduino Pro, it needs 100ms to get the triggerĭelay( 100) // hold the pin low long enough to trigger the board may need to be longer for consistent triggeringĭigitalWrite(pin, HIGH) // bring the pin high again to end the activationĪ simple trigger for the Adafruit Audio FX Sound Boardįor complete info on the sound board, see What I'm Doing Here PinMode(LED, OUTPUT) // Make the LED pin activeĭigitalWrite(pin, HIGH) // Set the pin high as the default stateĭigitalWrite(pin, LOW) // bring the pin low to begin the activationĪccording to the documentation, the Audio FX board needs 50ms to trigger. # define BUTTON 2 // put a simple button on pin 2 to enable/disable sound playback # define LED 13 // Most Arduinos have an LED on pin 13 Sound Board via a USB external battery for the initial tests, and the Arduino via the FTDI cable.įor later tests, I powered the Sound Board via the Arduino's VCC (3v) pin directly. Was connected to trigger pin #0 of the Sound Board, and I tied them to a common ground. This is a simple test of a direct trigger of the Audio FX Sounds Board from an Arduino.įor my test, I used an Arduino Pro Mini running at 3.3v & 8mHz. For complete info on the sound board, see A simple trigger for the Adafruit Audio FX Sound Board
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |