MiniBuild: Buzzicle Instrument

I needed a practical sound effect for a doorbell buzzer for the Old Time Radio Show at Anime Los Angeles this year. So I decided to build one with what I had on hand.

My inital thought was to replicate the mechanical buzzing by using a relay, but the only relays I have on hand have a 12v or 24v switching coil voltage, either one would require I use a transistor to trigger it and a 12v/24v power supply which makes things all too complicated.

Instead, I opted to use a small speaker and treat it like a pwm buzzer. Not perfect, but good enough, especially for something I only gave myself two hours to throw together. Rather than write code to only buzz the speaker when a button is pushed, I instead set the code to output the buzz all the time, put a switch in-line with the speaker thereby only completing the circuit when pushed.

As an example of scope creep, I thought, why not make the tone of buzz adjustable? To that end, I added a potentiometer into the mix, and mapped an array of tones to ranges of values from the pot. It ended up suddenly becoming a very stupid musical instrument.

The device stayed together and worked long enough to fill its role in the event, the promptly fell apart. Which is just fine. It’s literally held together by hotglue and tape, after all. I will take it apart and put the parts back in my parts pins for use again later!

Bill of Materials

  • Raspberry Pi Pico
  • Small Speaker
  • Push Button Switch
  • Rotary Potentiometer


Code

Python
import board
import simpleio
import digitalio
from analogio import AnalogIn
from adafruit_simplemath import map_range

TONE_FREQ = [ 60, #deep
              262,  # C4
              294,  # D4
              330,  # E4
              349,  # F4
              392,  # G4
              440,  # A4
              494,  # B4
              523]  # C5

analog_in = AnalogIn(board.A0)

while True:
    x = round(map_range(analog_in.value, 0, 65300, 8, 0))
    simpleio.tone(board.GP16, TONE_FREQ[x], duration=1)
    print(x)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.