Playground Drum Machine

A wise man once said, "Nothing sounds better than an Eight-O-Eight."

(That wise man was Adam Horovitz of the Beastie Boys.)

The 808 to which Ad-Rock was referring is the Roland TR-808 drum machine. Let's build a little Circuit Playground Express tribute to the venerable 808! Instead of a full-blown drum pattern sequencer, we'll just focus on the machine's pads which are used for finger drumming to play back sampled drum sounds.

We can use the capacitive touch pads on the Circuit Playground Express as triggers, and small .wav files for our drum sounds! 

First, download the .zip file below, which contains all of the drum samples we'll be using. Save the file to your desktop or somewhere else easy to find, and then unzip it.

You can plug in your Circuit Playground Express, and then drag the drum files onto it. It shows up as the CIRCUITPY drive.

Now, it's time to code the Circuit Playground Express! Copy the code shown below, and then paste it into your text editor of choice. Save the file as main.py (or code.py) on your CIRCUITPY.

# Playground 808
# Drum machine
from digitalio import DigitalInOut, Direction
import audioio
import touchio
import board
import time

bpm = 120 #beats per minute for sustained hold, change this to suit your tempo

# enable the speaker
spkrenable = DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = Direction.OUTPUT
spkrenable.value = True

# make the input cap sense pads
capPins = (board.A1, board.A2, board.A3, board.A4, board.A5,
           board.A6, board.A7)

touchPad = []
for i in range(7):
    touchPad.append(touchio.TouchIn(capPins[i]))

# The seven files assigned to the touchpads
audiofiles = ["bd_tek.wav", "elec_hi_snare.wav", "elec_cymbal.wav",
               "elec_blip2.wav", "bd_zome.wav", "bass_hit_c.wav",
               "drum_cowbell.wav"]

def play_file(filename):
    print("playing file "+filename)
    f = open(filename, "rb")
    a = audioio.AudioOut(board.A0, f)
    a.play()
    time.sleep(bpm/960) #sixteenthNote delay

while True:

    for i in range(7):
        if touchPad[i].value:
            play_file(audiofiles[i])

Try it out! When you tap the capacitive pads, the corresponding drum sample is triggered!!

Things are a bit crammed, admittedly, so you can try adding foil, copper tape, alligator clips, etc. in order to increase the surface area and physical space you have for your drumming!

Capacitance is calibrated at startup, so you may need to reset the board after attaching leads to the pads!

If you want to use your own sound files, you can! Record, sample, remix, or simply download files from a sound file sight, such as freesample.org. Then, to make sure you have the files converted to the proper specifications, check out this guide here that'll show you how! Spoiler alert: you'll need to make a small, 22Khz (or lower), 16 bit PCM, mono  .wav file!

Want to listen to your Drum Machine at body movin' volumes? No problem! Hook up an 1/8" or 1/4" phono output to the GND and A0 pads, then plug in to an amp!! I tried it on a small guitar amp and it sounds great.

Last updated on 2017-12-01 at 04.56.58 PM Published on 2017-10-12 at 10.43.39 PM