Party Necklace





Our team had come up with the challenge to design a unique gadget to wear to a costume party. With that being said, we will incorporate a battery-powered device using the Circuit Playground Express (CPX) that includes a moving part activated by a Servo Motor and meets a specific need. Our team will 3D print the casing and attachments on a Makerbot Sketch. The CPX and motor will be controlled by code that must involve lights and sounds that are activated by at least 3 different on-board sensors or buttons. The design will balance complexity, detail and quality. With the use of these elements and features, our team will be able to generate a unique gadget that can be worn to a costume party.
Supplies
Adafruit Circuit Playground Express Base Kit, Continuous Rotation Micro Servo, Alligator Clips to Male Wires and 3D Printer. https://www.adafruit.com/product/3517 https://www.adafruit.com/product/2442 https://www.adafruit.com/product/3448
Printing Example
First, download and print the following STL files using a 3d printer. Use a raft and supports. The files we used were designed using tinkerCAD, and the Mount was remixed from Adafruits Snap-fit Mount. You must now remove supports using cuticle cutters while welding the case to make holes for the clips to attach to the VOUT, A#, and GND. You also need to make another hole for the chargers- one for the battery and one for the USB cord.
Adafruit Coding Example
Follow these instructions to install CircuitPython onto your CPX: https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython
Than connect your CPX to your computer and save code.py onto it
The provided code will than:
Cause the motor to rotate clockwise when button A is pressed
Cause the motor to rotate counter-clockwise when button B is pressed
Light up when you shake it
SERVO MOTOR

To successfully attach the Servo Motor to the necklace, you first have to attach the Base piece to the CPX case. The Base piece is the piece that the Servo Motor case will attach to, You will do this by gluing the servo motor to the Base that you have just glued to the CPX case. Now you can put the servo motor in the servo motor case (although you might have to hot glue the piece to make sure it is completely stable. In the picture above, you can see the motor successfully attached to the servo motor case and the motor case is attached to the base piece.
Python Code
Below, I will have the copy-and-paste version of our Python code. It is recommended that the Adafruit code be used, but they both work well. This code will make the necklace light up as well as make noise.
import time
import math
from adafruit_circuitplayground.express import cpx
# Sound threshold – tweak this if needed
SOUND_THRESHOLD = 300 # adjust based on your environment
def rainbow_cycle(wait):
for j in range(255):
for i in range(10):
rc_index = (i * 256 // 10) + j
cpx.pixels[i] = wheel(rc_index & 255)
cpx.pixels.show()
time.sleep(wait)
def wheel(pos):
# Input a value 0 to 255 to get a color value.
if pos < 85:
return (255 - pos * 3, 0, pos * 3)
elif pos < 170:
pos -= 85
return (0, pos * 3, 255 - pos * 3)
else:
pos -= 170
return (pos * 3, 255 - pos * 3, 0)
# Main loop
while True:
sound_level = cpx.sound_level
print("Sound level:", sound_level) # for debugging via serial
if sound_level > SOUND_THRESHOLD:
print("Loud sound detected!")
rainbow_cycle(0.01) # play animation
# Play a tone when a loud sound is detected
cpx.play_tone(440, 0.5) # Play a 440Hz tone for 0.5 seconds
time.sleep(0.1) # small delay to avoid overwhelming the processor
Final Assembly
Going back to step 3, once you have successfully glued the servo motor to the motor case, the party necklace is basically assembled. You now just need to attach a string that can go around your neck to the circular notch at the top of the CPX case. Now all you have to do is clap to have the CPX light up and make noise; this is more than likely to happen at a party.