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 code editor of choice. Save the file as code.py on your CIRCUITPY drive.
# Circuit Playground 808 Drum machine import time import board import touchio import digitalio try: from audiocore import WaveFile except ImportError: from audioio import WaveFile try: from audioio import AudioOut except ImportError: try: from audiopwmio import PWMAudioOut as AudioOut except ImportError: pass # not always supported by every board! bpm = 120 # Beats per minute, change this to suit your tempo # Enable the speaker speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) speaker_enable.direction = digitalio.Direction.OUTPUT speaker_enable.value = True # Make the input capacitive touchpads capPins = (board.A1, board.A2, board.A3, board.A4, board.A5, board.A6, board.TX) 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"] audio = AudioOut(board.SPEAKER) def play_file(filename): print("playing file " + filename) file = open(filename, "rb") wave = WaveFile(file) audio.play(wave) time.sleep(bpm / 960) # Sixteenth note 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!
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/Audio pads, then plug in to an amp!! I tried it on a small guitar amp and it sounds great.