DJ Beatpad With Volume Adjustment and Speaker

by guomr in Circuits > Arduino

224 Views, 0 Favorites, 0 Comments

DJ Beatpad With Volume Adjustment and Speaker

IMG_7241.JPG

The inspiration for this project roots in my background in DJing and my love for music. Although the main equipment for DJs is turntables and mixers, some DJs also use beat pads to create new music on the spot. The beatpad I created brings music to life with infinite possibilities.

Supplies

Planning

I downloaded and used the console box template on Festi’s Boxes.py. Making adjustments to fit the vision of my project, I changed the size of the box by increasing the length. I also added holes for the buttons, speaker, potentiometer, and cables. Following, I imported my file into adobe and changed the color to Red (255, 0, 0) and the outline to 0.01mm. Once finished I downloaded my design onto a flash drive.

Cutting

Using the Trotec laser cutter, I cut out my pieces. For material, I chose dark blue ⅛” acrylic. I began by created a test cut in cardboard to test the fit of the box. After that, I used the blue acrylic to create the final box for the project.

Assembly

The acrylic I chose is fragile, so I carefully attached my pieces together. I then used super glue in weaker areas to make the box stronger.

Button Setup

I wrapped my button pieces (cut out peices from the box) in copper tape and attached mini wire loops on the back side. This allowed for an easy attachment system to my alligator clips.

Other Parts

Following, I attached my speaker, led strips, and potentiometer to the box. I connected the wires from both to my breadboard and capacitive touch sensor. I also attached my laser-cut CD to the servo motor and placed it in my turn table box.

Testing

Download the proper code to Arduino and make sure that it runs properly.

Code

import time, board, pwmio, adafruit_mpr121, neopixel

from analogio import AnalogIn


INDIGO = (63,0,255)

VIOLET = (127,0,255)

RED = (255,0,0)

MAGENTA = (255, 0, 255)

ORANGE = (255, 165, 0)

YELLOW = (255,255,0)

GREEN = (0,255,0)

JADE = (229, 223, 23)

BLUE = (0,0,255)

PURPLE = (106, 13, 173)

BLACK = (0,0,0)


colors = [RED,MAGENTA,ORANGE,YELLOW,GREEN,JADE,BLUE,INDIGO,VIOLET,PURPLE,BLACK]


strip = neopixel.NeoPixel(board.D2, 30, brightness=0.5, auto_write=True)


potentiometer = AnalogIn(board.A1)


i2c = board.I2C()

touch_pad = adafruit_mpr121.MPR121(i2c)


tone = pwmio.PWMOut(board.D3, variable_frequency=True)

volume = 50

tone.duty_cycle = volume


notes = [50, 70, 100, 120, 140, 160, 180, 200, 215, 230, 245, 250]

tone_duration = 0.2

rest_duration = 0.01


def play_a_tone(freq, volume):

  tone.duty_cycle = volume

  tone.frequency = freq



while True:

  strip.fill((0,0,0))

  touched = False

  volume = round(potentiometer.value/(65520/500))

  print(volume)

  for i in range(12):

    if touch_pad[i].value:

      print("You touched pad #{}!".format(i))

      play_a_tone(notes[i],volume)

      strip.fill(colors[i])

      touched = True

      time.sleep(0.05)

  if touched == False:

    tone.duty_cycle = 0

  time.sleep(0.05)