DIY USB MIDI Drum Kit using Maker Pi Pico and CircuitPython

Introduction

Turn your box into a simple drum kit!

Video

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is CircuitPython sample program and have been tested with CircuitPython 6.3.0. Before that, please include the following additional libraries:

  • adafruit_midi

You may download the CircuitPython Libraries Bundle ? here.

'''
References:
– Adafruit MIDI Library
https://circuitpython.readthedocs.io/projects/midi/en/latest/
– MatGyver DIY Electric MiDi Drum
https://matgyver.my/2021/06/29/diy-electric-midi-drum-piezo-electric/
CircuitPython libraries bundle: https://circuitpython.org/libraries
Additional libraries:
– adafruit_midi
Last Modified
– 13 July 2021
'''
import time
import board
from analogio import AnalogIn
import usb_midi
import adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff
from adafruit_midi.pitch_bend import PitchBend
from adafruit_midi.control_change import ControlChange
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=0)
piezo_1 = AnalogIn(board.A0)
piezo_2 = AnalogIn(board.A1)
snare_start = 5000
snare_stop = 2000
kick_start = 5000
kick_stop = 2000
snare_trigger = False
kick_trigger = False
print("Midi test")
print("Default output MIDI channel:", midi.out_channel + 1)
timer_1 = 0
timer_2 = 0
while True:
adc_piezo_1 = piezo_1.value
adc_piezo_2 = piezo_2.value
if adc_piezo_1 > kick_start and \
kick_trigger == False:
print((adc_piezo_1, adc_piezo_2))
timer_1 = time.monotonic()
midi.send([NoteOn(37, 120),
PitchBend(10000)])
midi.send([NoteOn(38, 120),
PitchBend(10000)])
kick_trigger = True
if adc_piezo_1 < kick_stop and \
kick_trigger == True and \
time.monotonic() timer_1 > 0.1:
timer_1 = 0
midi.send([NoteOff("C#1", 120),
ControlChange(3, 44)])
midi.send([NoteOff("D1", 120),
ControlChange(3, 44)])
kick_trigger = False
if adc_piezo_2 > snare_start and \
snare_trigger == False:
print((adc_piezo_1, adc_piezo_2))
timer_2 = time.monotonic()
midi.send([NoteOn(36, 120),
PitchBend(10000)])
midi.send([NoteOn(38, 120),
PitchBend(10000)])
snare_trigger = True
if adc_piezo_2 < snare_stop and \
snare_trigger == True and \
time.monotonic() timer_2 > 0.1:
timer_2 = 0
midi.send([NoteOff("C1", 120),
ControlChange(3, 44)])
midi.send([NoteOff("D1", 120),
ControlChange(3, 44)])
snare_trigger = False

view raw

code.py

hosted with ❤ by GitHub

Try Ableton Live for free (90 days) ? https://www.ableton.com/en/trial/

Thank You

References:

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for a better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Low Profile Aluminum Case and Icon Case Stress Test
DIY Digital Alarm Clock Using REKA:BIT With Micro:bit | Tutorial for Beginners
Send Temperature and Humidity Data To ThingSpeak Using micro:bit
DIY Interactive Robot using REKA:BIT with micro:bit | Tutorial for Beginners
Getting Started with the new Blynk IoT platform using Maker UNO
Tutorials of Cytron Technologies Scroll to Top