The concept for this project came about because one of my favorite hobbies is producing music on my MPC 1 Plus, a drum machine. The problem is I always found myself thinking of drum patterns when I was walking so that's how I came up with the plan to make a mini portable drum machine that you could use while just walking or something, on the go. It works like a simple drum machine with touch sensors as drum pads, a built in metronome, a record and play and pause function, and essentially all the most primitive functionality of a read drum machine on a small OLED screen with buttons and dials on the side for control.
Build InstructionsFirst I made a power and system block diagram that described all the main connections between the pocketbeagle and the electrical components.
System Block Diagram
Power Block Diagram
Specific Connections
From here it was all about just connecting the correct pins. I'll go component by component on how to connect everything correctly, however, the placement of the components themselves won't be established since it's more of a preference. Also to be honest, I'm not much of a fan of the placement of my components I think it lacks practicality. Below, you will find a diagram that shows what pins of the pocketbeagle do what, this will be especially useful to reference when connecting everything.
Now then, let's start with wiring the buttons. These operate on 3.3V, however, we can just use any set of GPIO pins on the pocketbeagle to connect to. Where the 3.3V comes in is that once a wire connects a pin on the button with a pin on the beagle, a pull up resistor (I used 4.4 kΩ), must be used to connect to the power line which is 3.3V. The second and last pin on a button is connected to ground.
After that come the capacitive touch sensors, these operate very similarly to 3.3V buttons, the only difference is that that these sensors have 3 pins, one signal, one ground, one power. Connect the ground to the ground of the breadboard, the power to the 3.3V power of the breadboard, and then the signal directly to a free GPIO pin.
Next are the 1.8V potentiometers. These are also pretty simple, there are 3 pins, signal, ground, and power. Wire them exactly like the touch sensors except this time make sure the power of the breadboard you are connecting to is 1.8V, and also the signal pin of the potentiometer must be connected to one of the AIN 1.8V pins (ideally pins 19-27), make sure these pins are NOT the REF- or REF+ AIN 1.8V pins on the beagle.
Then we got the USB port, there are four pins on it VBUS, DN, DP, and GND. This is important, first make sure on the beagle that VBUS and VIN (pins 5 and 7), and ID and GND (pins 13 and 15), are soldered together respectively. From here connect the wires according to the pin names as they are identical, I recommend connecting them beneath the beagle using flat wires.
Finally, the 7-Pin OLED SPI Screen. This was slightly confusing but here is the gist. This is a SPI Screen make no mistake, it has the following pins GND, VDD, CS, RST, SDA, SCLK, and DC. Do not get confused, the SDA is essentially just MOSI, and the SCLK is just CLK. Now I connected it like this: RST to P1_02, DC to P1_04, CS to P1_06, SCLK to P1_08, SDA to P1_12, VDD to P1_14, GND to P1_16.
That's all the electrical work done just repeat as many times as needed to do all the buttons, dials, etc, and use practical breadboard wiring knowledge plus the constraints of power and convenience to guide exact layout placement.
Operating InstructionsOperating the mini drum should be pretty intuitive as there is a whole program to go with it but here is some helpful starter information and also some specifics on how this basic mini drum actually works when you get to the sequencer.
Demo Run
Buttons
I had three buttons, a SELECT button, a RIGHT/UP button, and LEFT/DOWN button. Using these buttons you're able to navigate all the menus presented in the software.
Potentiometers/Dials
Also three dials, one dial controls the cursor/playhead on the sequencer and also a scale that pops up when on the tempo/BPM prompt box, another dial controls the volume of the sounds going through the audio output, and the last controls the brightness of the OLED SPI screen itself.
CapacitiveTouchSensors
There are also three touch sensors, these only control the specific samples that are installed in the samples library (currently labeled kick, snare, and crash).
USB Port for Audio
The USB port is the way to get audible sound. Simply connect your headphones or speaker through a standard 3.5mm audio jack cable and you're good to go.
Step-by-step Program Operation Instructions
1) Plug a micro usb cable between your computer and the pocketbeagle.
2) Go to cloud9, open a cloud9 terminal and cd into the folder holding the program in this case called MiniDrum.
3) in the terminal input: sudo python3 drummy_os.py
4) The terminal should say the drummy 3000 or something is booted, and on the screen a splash screen of a drum and sticks with a flashing start button prompt should pop up. (This is Screen 1)
5) Press the SELECT button
Side Note: From here on out you can change the volume or brightness when and as you place using the respective dials. The volume and brightness icons are found at the top of Screens 2 and 3, with a number next to it representing the magnitude of the respective setting based on the dials.
6) Now you should be on Screen 2 or the Browser screen, this works as a simple browsing system you can either make a New File or Open/Delete an exisiting file on the pocket beagle. Navigate this menu using the up and down buttons (or left/ and right) to hover onto a screen button and select that screen button using the select button. a) If you choose the New File it won't prompt anything and just open a new project going to Screen 3. b) If you select an old file it will prompt you with 3 screen buttons (back, del, load) select accordingly.
7) Assuming you either clicked New File or Load, you will be taken to Screen 3, the sequencer screen. There is a lot of information to be processed here so let's start from the bottom: the carousel of screen buttons.
I needed to put a lot of functionality into this screen so that it actually worked like a basic drum machine, the solution, a carousel of screen buttons that the user can scroll through depending on their need.
REC: Record whatever you play on the touch sensors, it will be over dubbed on an audio and json file that contains the graphical/text and audio information of your touches (so like what those touches mean). In general think of it as your "editor" state button for making loops. If you're already recording and you select the REC button again, it will stop the recording. Also a metronome at the tempo specified by the user will always play during a recording session in the background, its sound isn't actually registered onto the audio file, the number is though.
PLAY: Different from recording, play simply plays what you currently have on your loop file, so if you've recorded anything it will start wherever your cursor or playhead is at the time and play sounds from there based on the file.
STOP: Pause whatever you're playing at that moment and wherever the playhead is currenlty located at time wise, ;this does not work to pause a recording.
BPM: This button is meant to allow the user to edit the built in metronome (it's always on, I haven't built in an option to turn it off). When selected a prompt pops up with a number scale and a BACK button on the left and an OK button on the right. Use the left and right buttons to navigate the prompt, if you are hovering on the scale and then you select it with the SELECT button, you can then use the cursor dial to adjust the BPM or tempo of the metronome.
CLR: When selected it will prompt you with "Are you sure?" if you press OK it will clear the data recorded onto the file, letting you restart with ease. If you press back you simply go back to the sequencer.
SAVE: Save your file and your work by clicking save and overwriting your data.
EXIT: When selected it will prompt the same "Are you sure?" prompt as the CLR, though if you press OK it will return you to Screen 2, the browser screen.
Now then, lets move on to the main entree, the sequencer itself. In the middle of the screen you will see three rows divided in blocks of 32 each, Allowing you to register 32 sounds per row, each row corresponds to one touch sensor or sample. The blocks that you see in the rows represent your touch, so when the playhead goes over it, it will play the sound registered on that row at the time specified by the block. Right now I have the "kick" as the top row, "snare" as middle row, "crash" at bottom row.
And that's all of the programs functionality so far.
Challenges along the wayThere were several complications when making this lets go through them.
First off I had trouble with the pin connections, originally I had some wrong connections, and figuring out how to wire the SPI Screen was also a little weird because the pins on it weren't normal per se.
Next, I had finally come about my first iteration of the screen states. It definitely had a lot of work to still be done on it. The button presses still weren't synced with the software functionality. I only had the screen states but even those were still imperfect, I need to correct some graphics and whatnot. This was a lot of testing and changing as I saw fit, that's why I have test files to just test my code even though the files weren't working off each other yet.
After that I made my first working program, I called it Drummy OS, it registered button presses to navigate around, though I realized my brightness and volume weren't connected so I needed to add that functionality and then an audio manager and what so that I can actually start integrating the sound.
This is where I came to probably the most frustrating thing yet. My splash screen would pop up and I would press the SELECT button, but afterwards I would continuously get black screens and nothing worked. I thought it was my code at first, then I thought it was my screen that was broken only to realize it was my code the whole time. It was such a dumb mistake and I'm eternally grateful to ClaudeAI being able to help me trouble shoot in the end to figure out that I had set my minimum brightness to 0 and since my brightness dials weren't working properly I couldn't see anything after the splash screen cause those brightness settings don't affect the splash screen only what comes after. Claude suggested to correct it by making the minimum brightness 20, I decided to make the minimum 40 and it worked after that.
Finally, the last major obstacle was figuring out how to make it so my audio would actually work, this was also a lot of troubleshooting with AI to find my coding errors. In the end, I used mplayer package to load my audio, however, it comes with significant lag, but I know that if I had a better library it would work flawlessly so it's a compromise I can make, especially since it still works.
ImprovementsI have a couple of suggestions for improvements for this project and some things that I plan to change regardless.
First off, I want to change the layout of the electrical components, I want to reorient the screen and find a more stable place for the touch sensors. Ideally, the new layout would be accomodated with some type of mechanical structure so that it's more convenient to use; also just for aesthetics.
Then, I'd like to change my audio library package choice of mplayer to something more efficient that won't cause delay issues for my audio.
I'd also like to integrate a rechargeable battery to this system, so that the Mini Drum can run on it's own without power coming from my computer/pocketbeagle. With this I would also add a power button to make it fully independent from the computer and able to run on its own with no issues. This would also likely need some code that takes care of booting the system.
I'd also revise some of the buttons on the carousel on the sequencer screen (Screen 3). For example, the BPM button could use an off option to fully turn off the metronome as some users don't want a metronome at a time.
AcknowledgementsI would like to thank Erik Welsh for all the support with the project from helping me with the wiring to discussing the functionality of the drum machine and what other considerations I should make. Also, I would like to recognize the aid of generative AI such as Gemini and Claude to help me with some of the code for this project. This was a project that required a lot of coding so being able to save time wherever possible from taking care of repetitive code to helping me troubleshoot and correct errors. I also used it for some documentation of what I was doing as there were a lot of code files to keep up with and having there be a quick of summary of what I had done was helpful.










Comments