Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
![]() |
| × | 1 | |||
| × | 2 | ||||
| × | 16 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
![]() |
| |||||
Hand tools and fabrication machines | ||||||
![]() |
| |||||
![]() |
|
Playing funny sounds at random times always amused me. With a smartphone this is an easy task. But what's better than an app? Time to create some hardware to play annoying sounds!
This device is easy to operate and holds place for 16 soundboards, each containing 16 sounds. The soundboard can be choosen by pressing button 1 and 16 simultaneously. Now it's in soundboard selection mode. Simply press the desired soundboard button (1-16) and confirm with the same button.
Also the volume can be adjusted, simply by pressing button 1 and 16 simultaneously. Now it's in volume set mode. Simply press the desired volume button (1-16) and confirm with the same button.
Fabrication time!
Step 1First, start by printing all the enclosure parts.
While the printer creates all the parts, start assembling the custom PCB and solder the 16 led's for the trellis board.
First solder the headers on. Then start connecting the Trellis pad, OLED and Amp.
Take the enclosure mid part and slide 8 nuts into the nut holders.
Step 2Now take the enclosure mid and put in the PCB holder. After that you can slide in the speakers and the Oled.
Attach the PCB on the PCB holder using 3 screws and nuts. Then attach the speakers to the amp (in series). After uploading all your sounds to the Audio FX board, you can put this board on the PCB.
Now you can attach the Micro USB connector + cable to the bottom of the enclosure. Also screw the bottom to the mid part of the enclosure. Attach the USB to the feather and slide it into place on the PCB.
Now put the trellis holder on top of the speakers.
Put the trellis board on top of the trellis holder.
Now put the silicone buttons on top of the trellis board. After that you can put the top cover on the enclosure. Secure with 4 screws.
At the end, put the speaker covers and the feet into place.
Last but not least, insert the soundboard and audio file names in the code and upload it through the USB connector on the rear side.
Have fun!
/*********************************************************************
/*
Soundbox V2 code by WT040
Some snpippets of code are copied from the Adafruit library examples
History:
v2.0.0 25/08/2017 release version
*/
/*********************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Trellis.h>
#include "Adafruit_Soundboard.h"
#include "Arduino.h"
#include "wiring_private.h"
#define OLED_RESET 19
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
Adafruit_Trellis matrix0 = Adafruit_Trellis();
Adafruit_TrellisSet trellis = Adafruit_TrellisSet(&matrix0);
#define NUMTRELLIS 1
#define numKeys (NUMTRELLIS * 16)
#define INTPIN A2
#define SFX_RST 9
Uart Serial2(&sercom1, 11, 10, SERCOM_RX_PAD_0, UART_TX_PAD_2);
Adafruit_Soundboard sfx = Adafruit_Soundboard(&Serial2, NULL, SFX_RST);
boolean trackPlaying = false;
int trackToPlay = -1;
word volume = 10;
char* trackName = "";
char subTrackName[15] = "";
//edit this code to give the soundboards a name
char* soundBoards[] = {
"Soundboard 1",
"Soundboard 2",
"Soundboard 3",
"Soundboard 4",
"Soundboard 5",
"Soundboard 6",
"Soundboard 7",
"Soundboard 8",
"Soundboard 9",
"Soundboard 10",
"Soundboard 11",
"Soundboard 12",
"Soundboard 13",
"Soundboard 14",
"Soundboard 15",
"Soundboard 16"
};
//edit this code to give the sounda a (file) name
char* trellisPad1[16][16][2] = {
{ //Soundboard 1
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 2
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 3
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 4
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 5
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 6
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 7
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 8
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 9
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 10
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 11
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 12
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 13
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 14
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 15
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
{ //Soundboard 16
{ "T01RAND4WAV","test track" },
{ "T01RAND4WAV","test track 2" },
{ "00000003WAV","3" },
{ "00000004WAV","4" },
{ "00000005WAV","5" },
{ "00000006WAV","6" },
{ "00000007WAV","7" },
{ "00000008WAV","8" },
{ "00000009WAV","9" },
{ "00000010WAV","10" },
{ "00000011WAV","11" },
{ "00000012WAV","12" },
{ "00000013WAV","13" },
{ "00000014WAV","14" },
{ "00000015WAV","15" },
{ "00000016WAV","16" }
},
};
int amountOfKeysPressed = 0;
int trellisKeysPressed[16] = { false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false };
int volumeModeBtns[16] = { 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
word currentSoundboard = 0;
#define modePlay 1
#define modeSetVolume 2
#define modeSetSoundboard 3
int mode = modePlay;
void SERCOM1_Handler(){
Serial2.IrqHandler();
}
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
pinMode(INTPIN, INPUT);
digitalWrite(INTPIN, HIGH);
trellis.begin(0x70);
display.clearDisplay();
display.display();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.setTextWrap(false);
display.println("Soundbox v2");
display.display();
Serial2.begin(9600);
pinPeripheral(10, PIO_SERCOM);
pinPeripheral(11, PIO_SERCOM);
if (!sfx.reset()) {
Serial.println("Not found");
display.println(F("Couldn't find soundboard"));
display.display();
while (1);
}
else {
display.println(F("soundboard found"));
display.display();
}
delay(2000);
volume = sfx.volDown();
while (volume != 0) {
if (volume > 0) {
volume = sfx.volDown();
}
}
while (volume < 120) {
volume = sfx.volUp();
}
volume = 10;
showTrellisStartSequence();
showIdleDisplay();
}
void loop() {
if (!trackPlaying) {
readTrellis();
delay(250);
readTrellis();
}
delay(30);
checkInput();
if (trackPlaying && (trackToPlay > -1)) {
playTrack(trackToPlay);
}
}
void readTrellis() {
if (trellis.readSwitches()) {
// go through every button
for (uint8_t i = 0; i < numKeys; i++) {
if (trellis.justPressed(i)) {
trellisKeysPressed[i] = true;
}
if (trellis.justReleased(i)) {
trellisKeysPressed[i] = false;
}
}
}
}
void checkInput() {
amountOfKeysPressed = 0;
for (uint8_t i = 0; i < numKeys; i++) {
// if it was pressed...
if (trellisKeysPressed[i] == true) {
amountOfKeysPressed++;
}
}
if (amountOfKeysPressed == 1) {
for (uint8_t i = 0; i < numKeys; i++) {
if ((trellisKeysPressed[i] == true) && (mode == modePlay)) {
trackToPlay = i;
playTrack(trackToPlay);
}
if ((trellisKeysPressed[i] == true) && (mode == modeSetVolume)) {
if (i == volume) {
mode = modePlay;
for (uint8_t i = 0; i < numKeys; i++) {
trellis.clrLED(i);
}
trellis.blinkRate(0);
trellis.writeDisplay();
}
else if (i < 16) {
clearVolume();
while (i > volume) {
for (int t = 1; t < 12; t++) {
sfx.volUp();
}
volume++;
}
while (i < volume) {
for (int t = 1; t < 12; t++) {
sfx.volDown();
}
volume--;
}
printVolume();
for (uint8_t i = 0; i < numKeys; i++) {
if (i <= volume) {
trellis.setLED(i);
}
else {
trellis.clrLED(i);
}
}
trellis.writeDisplay();
}
}
if ((trellisKeysPressed[i] == true) && (mode == modeSetSoundboard)) {
if (i == currentSoundboard) {
mode = modePlay;
for (uint8_t i = 0; i < numKeys; i++) {
trellis.clrLED(i);
}
trellis.blinkRate(0);
trellis.writeDisplay();
}
else {
trellis.clrLED(currentSoundboard);
clearSoundboardName();
currentSoundboard = i;
printSoundboardName();
trellis.setLED(currentSoundboard);
trellis.writeDisplay();
}
}
}
}
if (amountOfKeysPressed == 2) {
Serial.println("2 buttons!");
if (trellisKeysPressed[0] && trellisKeysPressed[15]) {
mode = modeSetVolume;
trellis.blinkRate(1);
for (uint8_t i = 0; i < numKeys; i++) {
if (i <= volume) {
trellis.setLED(i);
}
else {
trellis.clrLED(i);
}
}
trellis.writeDisplay();
}
if (trellisKeysPressed[0] && trellisKeysPressed[1]) {
mode = modeSetSoundboard;
trellis.blinkRate(1);
trellis.setLED(currentSoundboard);
trellis.writeDisplay();
}
}
for (uint8_t i = 0; i < numKeys; i++) {
trellisKeysPressed[i] = false;
}
}
void playTrack(int key) {
uint32_t current, total;
trackPlaying = true;
trackName = trellisPad1[currentSoundboard][key][1];
display.setCursor(14, 31);
if (strlen(trackName) > 18) {
strncpy(subTrackName, trackName, 15);
display.print(subTrackName);
display.print("...");
}
else {
display.print(trackName);
}
display.display();
trellis.setLED(key);
trellis.writeDisplay();
Serial.println(trellisPad1[currentSoundboard][key][0]);
sfx.playTrack(trellisPad1[currentSoundboard][key][0]);
delay(1000);
if (!sfx.trackTime(¤t, &total))
Serial.println("Failed to query");
Serial.print(current); Serial.println(" seconds");
delay ((total*1000)+2000);
trellis.clrLED(key);
trellis.writeDisplay();
trackPlaying = false;
trackToPlay = -1;
display.setCursor(14, 31);
display.setTextColor(BLACK);
if (strlen(trackName) > 18) {
strncpy(subTrackName, trackName, 15);
display.print(subTrackName);
display.print("...");
}
else {
display.print(trackName);
}
display.display();
display.setTextColor(WHITE);
}
uint32_t trackLength(char trackName) {
uint32_t trash, length;
sfx.trackTime(&trash, &length);
Serial.println(length);
return length;
}
void showTrellisStartSequence() {
for (uint8_t i = 0; i<numKeys; i++) {
trellis.setLED(i);
trellis.writeDisplay();
delay(50);
}
for (uint8_t i = 0; i<numKeys; i++) {
trellis.clrLED(i);
trellis.writeDisplay();
delay(50);
}
}
void showIdleDisplay() {
display.setTextSize(1);
display.clearDisplay();
display.setCursor(30, 0);
display.print("Soundbox 2");
display.setTextSize(1);
display.setCursor(20, 10);
display.print("Push to annoy!");
display.drawLine(0, 19, 128, 19, WHITE);
display.setCursor(0, 31);
display.write(14);
display.print(": ");
display.setCursor(83, 56);
display.print("Vol: ");
display.display();
printSoundboardName();
printVolume();
}
void printSoundboardName() {
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 23);
display.write(64);
display.print(": ");
display.setCursor(14, 23);
display.print(soundBoards[currentSoundboard]);
display.display();
}
void clearSoundboardName() {
display.setTextSize(1);
display.setCursor(14, 23);
display.setTextColor(BLACK);
display.print(soundBoards[currentSoundboard]);
display.display();
}
void printVolume() {
display.setCursor(110, 56);
display.setTextColor(WHITE);
display.print(volume, DEC);
display.display();
}
void clearVolume() {
display.setCursor(110, 56);
display.setTextColor(BLACK);
display.print(volume, DEC);
display.display();
}
Comments
Please log in or sign up to comment.