Sound and Music Sensing Quartz Crystal Brooch With Playground Circuit Express

by sfscherini in Circuits > Wearables

1621 Views, 9 Favorites, 0 Comments

Sound and Music Sensing Quartz Crystal Brooch With Playground Circuit Express

Test 1
stillimage.jpg
IMG_6507.jpg

This sound-reactive brooch is made using a playground circuit express, cheap bulk quartz crystals, wire, cardboard, found plastic, a safety pin, needle and thread, hot glue, fabric, and a variety of tools. This is a prototype, or first draft, of this design.

Having some level of knowledge when it comes to working with wire is helpful, but not necessary! Introductory programming knowledge may aid as well, but it's easy to learn using playground circuit express and related programs.
This project could take anywhere from a handful of hours to a few days, depending on your method of construction and attention to detail.

Supplies

- Playground Circuit Express with battery pack and circuit to USB cable

- Quartz Crystals

- Jewelry Wire (any color is ok, stick to a gauge that is easily workable for you! I used 20 gauge)

- Cardboard

- Found Clear Plastic (I used a lid of a coffee can)

- Safety Pin

- Fabric (Your choice - I used an old black t-shirt)

- Hot Glue Gun and Glue Sticks

- Scissors

- Pencil

- Sharpie

- Needle-nose pliers and wire cutters

- Optional: Needle and Thread

- Optional: Two-sided Velcro Tape

Gauge the Size

IMG_6460.jpg
IMG_6461.jpg

Trace the Playground Circuit Express on a piece of paper or cardboard. Cut it out.
You now have a template to use while creating your structure. Put the Circuit Express somewhere safe!

Create the Brooch

IMG_6463.jpg
IMG_6466.jpg
IMG_6469.jpg
IMG_6472.jpg
IMG_6476.jpg

Cut a long length of wire and begin working it into a hoop, using your paper template as a guide for size. You want it to be slightly larger than the template.
Next, begin building up the wire on one side, into a dome shape. Be mindful of where the crystals will fit, but make sure they are pointing upwards only (allow room for the playground circuit express to still fit underneath)!

Start placing your crystal points, using the wire to wrap around and connect. Feel free to fix some in place with a dot of hot glue. Continue until the quartz covers the structure and you're satisfied with the composition.

Create a Backing

IMG_6478.jpg
IMG_6479.jpg

Using your found clear plastic, trace your template using a sharpie.
Cut this out with scissors, and attach to the back of your brooch using hot glue.

Build Your Circuit Holder

IMG_6489 (1).jpg
IMG_6491.jpg
IMG_6494.jpg

Grab that template again! Trace around it on a piece of cardboard, but make sure to leave approximately 1/4" around the template on all sides. Cut this out, and trace it several more times on cardboard (at least five).

Glue three of the cardboard circles together.

Take the additional circles and cut them in half. Cut a "lip" with scissors (as shown in the photos) and glue 2-3 of these together on one side of the cardboard form.

You should end up with a thick, cardboard circle that will effectively "hold" your circuit.

Attach!

IMG_6496.jpg
IMG_6502.jpg

Using the fabric of your choice and the method of your choice (hot glue, needle and thread), "upholster" your cardboard structure. Be sure to press the fabric down into the "lip".

After attaching the fabric, use hot glue (and/or again, needle and thread) to attach the crystal structure to the raised lip. It should sit securely, with a gap still open for the playground circuit express to fit in later.

Then, glue a safety pin (or a pin attachment) to the back of the brooch.

Test the Fit!

IMG_6580.jpg
IMG_6499.jpg

Your brooch should be assembled now.
Test the fit of your playground circuit express in your brooch. It should fit snugly and hold.
If it's a little loose and tries to slip out, consider placing a small piece of Velcro tape on the back of the PCE, and the other piece on the inside of your brooch's opening.

Code

PythonCodeScreenshot.jpg
lights crystals play 2.jpg

- Go To: https://codewith.mu/

- Install the correct installation for your system

- Search for and Run "Mu" App

- Plug In your Playground Circuit Express

The App should sense your input, and should automatically transfer code to your PCE.

- Borrow some Code! The Code I borrowed and edited slightly is from Adafruit and MIT

You can play around with colors, etc! OR - make your own code by going to: MakeCode

Here is the code I used if you'd prefer to just copy and paste directly:

import array
import math import audiobusio import board import neopixel # Exponential scaling factor. # Should probably be in range -10 .. 10 to be reasonable. CURVE = 2 SCALE_EXPONENT = math.pow(10, CURVE * -0.1) PEAK_COLOR = (100, 0, 255) NUM_PIXELS = 10 # Number of samples to read at once. NUM_SAMPLES = 160 # Restrict value to be between floor and ceiling. def constrain(value, floor, ceiling): return max(floor, min(value, ceiling)) # Scale input_value between output_min and output_max, exponentially. def log_scale(input_value, input_min, input_max, output_min, output_max): normalized_input_value = (input_value - input_min) / \ (input_max - input_min) return output_min + \ math.pow(normalized_input_value, SCALE_EXPONENT) \ * (output_max - output_min) # Remove DC bias before computing RMS. def normalized_rms(values): minbuf = int(mean(values)) samples_sum = sum( float(sample - minbuf) * (sample - minbuf) for sample in values ) return math.sqrt(samples_sum / len(values)) def mean(values): return sum(values) / len(values) def volume_color(volume): return 200, volume * (255 // NUM_PIXELS), 0 # Main program # Set up NeoPixels and turn them all off. pixels = neopixel.NeoPixel(board.NEOPIXEL, NUM_PIXELS, brightness=0.1, auto_write=False) pixels.fill(0) pixels.show()

""" # For CircuitPython 2.x: mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, frequency=16000, bit_depth=16) # For Circuitpython 3.0 and up, "frequency" is now called "sample_rate". # Comment the lines above and uncomment the lines below. """ mic = audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) # Record an initial sample to calibrate. Assume it's quiet when we start. samples = array.array('H', [0] * NUM_SAMPLES) mic.record(samples, len(samples)) # Set lowest level to expect, plus a little. input_floor = normalized_rms(samples) + 10 # OR: used a fixed floor # input_floor = 50 # You might want to print the input_floor to help adjust other values. # print(input_floor) # Corresponds to sensitivity: lower means more pixels light up with lower sound # Adjust this as you see fit. input_ceiling = input_floor + 500 peak = 0 while True: mic.record(samples, len(samples)) magnitude = normalized_rms(samples) # You might want to print this to see the values. # print(magnitude) # Compute scaled logarithmic reading in the range 0 to NUM_PIXELS c = log_scale(constrain(magnitude, input_floor, input_ceiling), input_floor, input_ceiling, 0, NUM_PIXELS) # Light up pixels that are below the scaled and interpolated magnitude. pixels.fill(0) for i in range(NUM_PIXELS): if i < c: pixels[i] = volume_color(i) # Light up the peak pixel and animate it slowly dropping. if c >= peak: peak = min(c, NUM_PIXELS - 1) elif peak > 0: peak = peak - 1 if peak > 0: pixels[int(peak)] = PEAK_COLOR pixels.show()

Finish and Wear!

IMG_1864.jpg
Test 3

You're welcome to just admire your sound-reactive crystal as is, but I recommend:

- Unplug the USB cable from the laptop (ensuring the code has transferred)
- Plug your Playground Circuit Express into the battery pack
- Insert the PCE into your brooch
- Either put the battery pack into a front shirt pocket (as I did here) or clip it to your shirt
- Pin the Brooch, turn some music (and your battery pack) on, and enjoy!