/*
Menu driven control of a sound board over UART.
Commands for playing by # or by name (full 11-char name)
Hard reset and List files (when not playing audio)
Vol + and - (only when not playing audio)
Pause, unpause, quit playing (when playing audio)
Current play time, and bytes remaining & total bytes (when playing audio)
Connect UG to ground to have the sound board boot into UART mode
*/
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"
// Choose any two pins that can be used with SoftwareSerial to RX & TX
#define SFX_TX 5
#define SFX_RX 6
// Connect to the RST pin on the Sound Board
#define SFX_RST 4
// You can also monitor the ACT pin for when audio is playing!
// we'll be using software serial
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
// pass the software serial to Adafruit_soundboard, the second
// argument is the debug port (not used really) and the third
// arg is the reset pin
Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, SFX_RST);
// can also try hardware serial with
// Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial1, NULL, SFX_RST);
const int buttonPin = 2;
const int buttonPin2 = 3;
int buttonState = 0;
int button2State = 0;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean lastButton2 = LOW;
boolean currentButton2 = LOW;
void setup() {
ss.begin(9600);
}
boolean debounce(boolean last)
{
boolean current = digitalRead(buttonPin);
if (last != current) {
delay(5);
current = digitalRead(buttonPin);
return current;
boolean current = digitalRead(buttonPin2);
if (last != current) {
delay(5);
current = digitalRead(buttonPin2);
return current;
}
}
}
void loop() {
// get the control switch's position
currentButton = debounce(lastButton);
if (lastButton != currentButton) { //the switch position changed
lastButton = currentButton;
if (currentButton == HIGH) {
// - play a sound and wait for it to finish
sfx.playTrack("TAKEOMHDOGG");
}
}
}
/************************ MENU HELPERS ***************************/
I need Help with the posted code . I have 5 sound files on the adafriut board , and I got one button to control the named file, But every time I try to add a second button and sound file using the if statement , it wont play that file .
it is uart control . one rtx pin , If that helps , this is totally new to me, my major goal is to have a monolog going with ws2812 rgb leds flash to that monolog , Like I've stated , I have 5 sound bites
the attached fritzing file is just a rough diagram , to give you all an idea, 5 buttons into one uart rtx pin
Any great advice is surely welcome and very appreciated
Thank You
And Happy Programming