-
1Drum 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.
-
2Brain and Brawn of this project: Raspberry Pi Pico 2 and DFMini Player Module
We 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.
-
3Wiring 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.
-
4Main Sketch
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 corresponding
noteFiles
index is passed to triggerplay(),
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.
-
5Result
A 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.
-
6what's next
This 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!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.