Greetings everyone and welcome back. Here's something loud.
The Pico Drum Machine is a DIY drum machine powered by the Raspberry Pi Pico 2 combined with the DF Mini player and a custom button board.
We wanted to test out an experimental setup that consists of a PICO paired with a DFMini player and a button board. Audio files on the SD card of DFplayer will be played when any button is pressed. Each button corresponds to each audio file. Here, the drum machine was to be controlled via this logic.
To test this idea out, we developed a simple 8-button breakout board in which all buttons are linked to GND and have 8 separate pinouts for each button; all buttons will be connected to Pico in the INPUT_PULLUP configuration.
In terms of sound, we downloaded the Audio Notes or recordings of Drum Kit instruments such as the bass drum, cymbals (Crash, Ride, Splash), snare drum, and tom-toms.
This article is about the whole build process of this project so let's get started with the build.
Materials RequiredThese were the materials used in this build:
- Raspberry Pi Pico 2
- Custom PCB
- 12x12 Tacktile Switches
- CON9 Header Pin
- Breadboard
- Jumper Wires
- Speaker 2Ohms
- SD Card
- Audio Files
- DFMini Player
We started this project by creating a schematic for the button board,, which consists of eight push buttons. Each button's NC terminal is linked to GND, all eight buttons NO Terminals are connected in a sequential manner to the terminals of the CON9 header pin, as well as the ground port. This header pin will be used to mount the button board on a breadboard and interface it with the Pico 2.
Using Fusion360, we generated a basic model with all of the switches allocated to their respective positions, as well as four mounting holes in case this board needs to be attached to a body.
We built the board file based on the Cad file dimensions and positioned the switch exactly where it should be.
We complete the board by joining all the traces and creating the gerber data for the PCB.
Seeed Studio FusionFollowing the completion of the Gerber data, we uploaded the file to Seeed Fusion's website and placed an order for a yellow Solder mask with white silkscreen.
PCBs were received in a week, and their quality was super good considering the rate, which was also pretty low.
Seeed Fusion PCB Service offers one-stop prototyping for PCB manufacture and PCB assembly, and as a result, they produce superior-quality PCBs and fast turnkey PCBAs within 7 working days.
Seeed Studio Fusion PCB Assembly Service takes care of the entire fabrication process, from Seeed Studio Fusion Agile manufacturing and hardware customization to parts sourcing, assembly, and testing services, so you can be sure that they are getting a quality product.
After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.
Drum Machine Button Circuit Assembly- We begin the button circuit-built procedure by positioning all of the buttons on the top side of the board.
- Next, we turn the board over and solder all of the button pads with a soldering iron.
- We then placed the CON9 header pin from the bottom side of the board and soldered its pads from the top side.
The button circuit assembly process has been completed.
Brain and Brawn of this project: Raspberry Pi Pico 2 and DFMini Player ModuleWe select to utilize the Raspberry Pi PICO 2 as the brain of this project, along with the DFmini player as the brawn.
The primary controlling part is done by the NEW RASPBERRY PI PICO 2, which is the upgraded and powerful microcontroller board centered upon the RP2350 microcontroller, the new Dual Arm Cortex-M33 or dual RISC-V Hazard3 cores running at 150 MHz and 520 KB on-chip SRAM and 4 MB on-board QSPI flash.
The DFmini Player is a mini MP3 Player Module that is based around a 24-bit DAC IC along with an onboard SD Card reader that fully supports the FAT16 and FAT32 file systems.
This module supports a variety of control modes, including I/O control mode, serial mode, AD button control mode, etc., meaning the user can use this board as a standalone device or use an external microcontroller to drive the module.
For more info about this module, you can checkout its product wiki published by DFROBOT.
https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299
Wiring Diagram- Let's start the wiring process of this project, which was quite straightforward. We first connect the GND of PICO2, DFmini player, and Switch board together.
- Next, we connected the VCC of the DFmini player with PICO's VBUS terminal.
- The first switch connected to GPIO14, the second to GPIO15, the third to GPIO16, the fourth to GPIO17, the fifth to GPIO18, the sixth to GPIO19, the seventh to GPIO20, and the eighth to GPIO21.
- The speaker is connected to the DF player's Speaker 1 and 2 pins.
Here's the sketch that we used in this project and its a simple one.
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
// Declare button pins for 8 buttons
const int buttonPins[8] = {14, 15, 16, 17, 18, 19, 20, 21}; // Adjust pins as per your setup
const int noteFiles[8] = {1, 2, 3, 4, 5, 6, 7, 8}; // Corresponding note numbers
// DFPlayer connections
SoftwareSerial mySerial(9, 8); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
Serial.println("Initializing DFPlayer...");
if (!myDFPlayer.begin(mySerial)) {
Serial.println("Unable to begin:");
Serial.println("1. Recheck the connection!");
Serial.println("2. Insert the SD card!");
while (true);
}
Serial.println("DFPlayer Mini online.");
for (int i = 0; i < 8; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
myDFPlayer.volume(30); // Set volume to maximum
Serial.println("Setup complete. Ready to play notes.");
}
void loop() {
for (int i = 0; i < 8; i++) {
if (digitalRead(buttonPins[i]) == LOW) { // The button is pressed
Serial.print("Button ");
Serial.print(i + 1); // Shift to human-readable (1-based indexing)
Serial.println(" pressed.");
myDFPlayer.play(noteFiles[i]); // Play the note directly
Serial.print("Playing note ");
Serial.println(noteFiles[i]);
delay(150); // Reduced debounce delay for faster response
}
}
}
This sketch is designed to play audio notes using the DFPlayer Mini module when specific buttons are pressed.
When a button is pressed, the correspondingnoteFiles
index is passed to play(),
triggering playback of the corresponding audio file on the DFPlayer Mini. Simply put, it tells the DFPlayer Mini to play the audio file corresponding to the button pressed.
Make sure to install the below libraries before using this sketch.
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
The audio files used in this project are attached in Attachments.
ResultA functional drum machine that plays audio files when any of the eight buttons are hit is the final result of this little project. Each button corresponds to a single audio file saved on the SD card; when we push the button, the audio track is played. We have released a YouTube short that you may view; it demonstrates a testing video of the setup.
Using this arrangement, we may connect several buttons to increase the amount of files or fully replace the audio files with other instrument audio files. This project may be used to create a piano instead of a drum set, a flute, a harmonium, or a violin.
what's nextThis project finished with a functional drum machine that features seven drum kit pieces and one extra cymbal sound, making it an eight-part drum kit.
This was just an experiment setup to see how well the idea of storing audio files to an SD card and playing them with the push of a button worked. This idea worked, and we can now move on to version 2 of this project, which would be a much larger and more professional-looking drum kit or a device with buttons that can be programmed to mimic any instrument by writing notes to an SD card and pressing buttons to play the notes.
One thing I'd like to change in edition 2 is to utilize silent buttons, because because we don't have a strong speaker, we can plainly hear the button push sound above the played note, which is not ideal. To combat this, we may build our drum set with silent mechanical switches, increase the number of buttons, and add an internal amplifier and battery pack to make it portable and powerful.
Leave a comment if you need any help regarding this project. This is it for today, folks.
Thanks to Seeed Studio Fusion for supporting this project.
You guys can check them out if you need great PCB and stencil service for less cost and great quality.
And I'll be back with a new project pretty soon!
Comments