NederlandsKlik deze knop voor de Nederlandstalige website

Arduino Halloween MP3 Soundboard

This Arduino Halloween Soundboard is again a simple project built with parts that I already had. The soundboard is very simple. There are 16 MP3s on the SD card. As soon as one of the 16 keys of the keypad is pressed, the Arduino plays the corresponding MP3 over the loudspeaker. While an MP3 is playing you can press another key, the playback will be cut off and the next sound will start immediately.

Just like the previous Halloween project “Lightning & thunder: Arduino Halloween DIY project” we use the DFPlayer Mini. In addition, this time also a 4×4 keypad is present. This is not a ready-made project but a starting point, you can use it to make something fun yourself. In this blog, we use the soundboard with Halloween sounds, but you can of course also use it with other samples.

Arduino Halloween MP3 Soundboard: components
Arduino Halloween MP3 Soundboard: components
Geekcreit® UNO R3 ATmega328P Development Board For Arduino
Tested and recommended by OneGuyOneBlog.com:

Geekcreit® UNO R3 ATmega328P Development Board For Arduino
Banggood.com

Arduino Halloween MP3 Soundboard

I use the following components for this project. The speaker is recycled from an old PC.

If you have all the parts together then connect it as indicated in the diagram below.

Arduino Halloween MP3 Soundboard: breadboard view
Arduino Halloween MP3 Soundboard: breadboard view

You connect the keypad to the digital pins of the Arduino according to the table below. Pin 1 of the keypad is the left pin on the connector (the keypad with the printed side up, as in the pictures).

Keypad pin Arduino digital pin
1 5
2 4
3 3
4 2
5 9
6 8
7 7
8 6

The DFPlayer Mini is connected to pin 10 and pin 11 (with 1K resistor), as well as 5V and GND:

DFPlayer Mini Arduino digital pin
TX 10
RX 11 (via 1K resistor)
VCC 5V
GND GND

In the example, the DFPlayer Mini is connected to a speaker, but you can also use an amplifier. Both options are listed in the table below:

DFPlayer Mini Speaker Amplifier
SPK_1 +
SPK_2
DAC_L L
DAC_R R
GND GND
DFPlayer Mini pins
DFPlayer Mini pins

More information about connecting the DFPlayer Mini can be found on the DFRobot Wiki.

Halloween sounds, the MP3s

You can find a ready-made set of 16 Halloween sounds in MP3 format (320kbps) in the downloads section or download via the link below. The files (0001.mp3 to 0016.mp3) must be placed in a folder with the name “mp3” on the SD card. The card may be FAT16 or FAT32 formatted. These sounds are just randomly chosen examples, it is, of course, more fun to search for sounds yourself.

Installing the Arduino libraries

To make programming a bit easier we use libraries for the keypad and the DFPlayer Mini. You can install the libraries in “Library Manager” which you can access via the menu Tools > Manage libraries …

First, the keypad Library (https://playground.arduino.cc/Code/Keypad/). Search for ‘keypad’ and choose the library as shown in the image below.

Installing the keypad library
Installing the keypad library

Then we install the DFRobotDFPlayerMini library (https://github.com/DFRobot/DFRobotDFPlayerMini). Search for “DFRobotDFPlayer” and choose the library named “DFRobotDFPlayerMini”.

Installing the DFPlayer library
Installing the DFPlayer library

When these two libraries are installed, we can continue with the code for the soundboard.

Arduino Halloween Soundboard Code

The code is also just an example and a starting point for creating your own creations. The code below is based on the sample “HelloKeypad”. More examples can be found in the Arduino IDE under the menu File > Examples > Keypad.

#include "Keypad.h"
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns

char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

String keypadKeys = "1234567890*#ABCD";

void setup(){
  mySoftwareSerial.begin(9600);
  Serial.begin(9600);

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }

  myDFPlayer.volume(25);  //Set volume value. From 0 to 30
}
  
void loop(){
  char keyPressed = keypad.getKey();
  
  if (keyPressed){
    Serial.println(keyPressed);
    int sampleIndex = 1 + keypadKeys.indexOf(keyPressed); //Convert pressed key (1234567890*#ABCD) to sample index (1-16)
    Serial.println(sampleIndex);
    myDFPlayer.play(sampleIndex);  //Play the chosen mp3
  }
}

To be continued

You can go so many ways with a project like this that we will undoubtedly come back to it again. What else could we do with it?

  • Build in a funny housing
  • Choose a different theme than Halloween
  • Have the A-B-C-D keys select a “sound bank” so that you can play more sounds
  • Connect an OLED or LCD display, LEDs, etc.
  • create a WiFi version with an ESP8266 or ESP32
  • Etc. etc. etc.

Plenty of options! Have you made a nice project with it yourself? Put it in the comments below!

Geekcreit® UNO R3 ATmega328P Development Board For Arduino
Tested and recommended by OneGuyOneBlog.com:

Geekcreit® UNO R3 ATmega328P Development Board For Arduino
Banggood.com
DFPlayer Mini MP3 Player Module For Arduino
Tested and recommended by OneGuyOneBlog.com:

DFPlayer Mini MP3 Player Module For Arduino
Banggood.com
16Keys 4 x 4 SCM Matrix External Expansion Keyboard Contral Board
Tested and recommended by OneGuyOneBlog.com:

16Keys 4 x 4 SCM Matrix External Expansion Keyboard Contral Board
Banggood.com
300Pcs 1% 1/4W Metal Film Resistor Resistance 30 Values Assortment Kit
Tested and recommended by OneGuyOneBlog.com:

300Pcs 1% 1/4W Metal Film Resistor Resistance 30 Values Assortment Kit
Banggood.com
8.5 x 5.5cm 400 Tie Points 400 Holes Solderless Breadboard Bread Board
Tested and recommended by OneGuyOneBlog.com:

8.5 x 5.5cm 400 Tie Points 400 Holes Solderless Breadboard Bread Board
Banggood.com
65 Pcs Breadboard Jumper Connect Cable Adapter Cable
Tested and recommended by OneGuyOneBlog.com:

65 Pcs Breadboard Jumper Connect Cable Adapter Cable
Banggood.com
8G Micro SD TF Micro SD Card For Cell Phone MP3 MP4 Camera
Tested and recommended by OneGuyOneBlog.com:

8G Micro SD TF Micro SD Card For Cell Phone MP3 MP4 Camera
Banggood.com

Add a Comment

Your email address will not be published. Required fields are marked *