This is the Multi-button Synth in "button play mode."
(UPDATE: The next version of this project is done, see the "16-button sequence synthesizer.")
What’s the logical next step to a synthesizer? Playing multiple sounds or melodies. Accessible by multiple buttons. That’s my goal in this week’s Microbit project.
To take the concept a little further, I wanted to have a way to sequence and time when I play different sounds. To make a basic version of this idea, I will use the Micro:bit music library. It’s not the most modern music out there… but it serves this purpose.
The software works as follows:
- Power it up, it ready to play tones/music. Press any of the eight buttons, and it will play a different melody. This is the button play mode.
- Press both “A” and “B” simultaneously and it will go into record mode. When you press any of the eight buttons and it will play the melody for as long as you hold the button down. You can press and hold any sequence of buttons, and it will record the sequence and timing.
- Press “B” to playback your recording.
- Press “A” to return to the button play mode, and will stop playing the recording.
First, let’s gather all the necessary components you’ll need to build this project.
Project Wires Female - Female (aka jumper wires)
1x Piezo Buzzer (Alternative option - Powered speaker.)
Video demonstration of the project:
STEP 1
Load the code onto the Micro:bit.
I am providing the hex file you need to drag and drop onto the Micro:bit, and the python code as two separate files. For the below process, just use the hex file.
Plug the MicroUSB cable into the Micro:bit, and plug the other end of the cable to a PC or MAC.
At this point, you are going to copy over the code to the Micro:bit. I am providing the program (code) in this post that needs to be copied over. When the Micro:bit plugs into a computer, it shows up as a USB flash drive. All you have to do is copy the file over to the Micro:bit, like it’s a USB Flash Drive, and the Micro:bit will reset, and the program is active.
You can remove the Micro:bit from the computer at this point. The program will start running, and without the rest of the circuit, it will not function.
●
A little bit about the code:
Note the import music definition. It allows access to standard melody sound clips. See the musicClips variable for the name of each sound it plays.
Import utime is used for timing the sequences.
The rest of the code is commented fairly well if you want to see what is going on in it.
STEP 2
I used a 4x4 matrix keypad for this project. You can use any type of matrix keypad as long as it has eight buttons.
I then used female-female project wires to connect the pad to the Micro:bit breakout board.
STEP 3
Wire up the schematic to the breakout board.
STEP 4
Setup
Plug USB 5V power to the Micro:bit.
It will be in the button play mode. You should see a play symbol triangle alternate with a hyphen.
In this mode, buttons K1 to K8 play eight different melodies numbered 0-7. Press the different buttons to hear the melodies. As soon as you press a new button, the old melody will stop playing.
Simultaneously pressing “A” and “B” keys will switch mode to the “Rec” displaying on the LED indicator as a circle interchanging with its half (to reserve two upper lines for the storage indicator).
As you press keys their keycodes and successive relative time intervals are stored in the memory. “No input” is coded as “-1” and its duration is stored too so any key press uses 2 elements (coding pressed key and released keys relative time intervals).
To replay recorded sequence press button “B.” “Replay” mode is started and keys are replayed sequentially until the last stored key release event, ended by “A” or “B” key press and continues in infinite loop (until “A” or “B” button key press).
Conclusion:
This is the first step to multi-button sequence synthesizer on a Micro:bit. Alternatively, it is a way to play custom melodies too.
Top Comments