jack
Published

Zen Drum

This device mimics the sounds that a "Hang" makes and lights up underneath for a mesmerizing experience.

IntermediateShowcase (no instructions)192
Zen Drum

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Alligator Clips
Alligator Clips
×1
Speaker: 3W, 4 ohms
Speaker: 3W, 4 ohms
×1
Aluminum Foil
×1

Story

Read more

Schematics

20201110_124731_sSr3b56JqA.jpg

Code

Code

Python
# Circuit Playground 808 Drum machine
import time
import board
import touchio
import digitalio
from random import *


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 = ["A07.wav", "B07.wav", "D07.wav",
              "E07.wav", "F07.wav", "H07.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 / 300)

while True:


        if touchPad[0].value:
            play_file("A07.wav")

        if touchPad[1].value:
            play_file("B07.wav")

        if touchPad[2].value:
            play_file("D07.wav")

        if touchPad[3].value:
            play_file("E07.wav")

        if touchPad[4].value:
            play_file("F07.wav")

        if touchPad[5].value:
            play_file("H07.wav")

Credits

jack
4 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.