Alex BeckQing WeiSunny
Created March 30, 2020 © GPL3+

Phillar Magic Symphony

A wand that plays music as the user moves it around.

Intermediate7 hours20
Phillar Magic Symphony

Things used in this project

Hardware components

Circuit Playground Express
Adafruit Circuit Playground Express
×1
Breadboard (generic)
Breadboard (generic)
×1
Alligator Clips
Alligator Clips
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1

Story

Read more

Custom parts and enclosures

Beginning Construction

With a quick sketch of how to build the basket, and how to accomodate the hardware, we began reinforcing paper shapes with gorilla tape

Basket's coming together

We have the start of a 3D shape! Taping the final side gives us a base for the basket

Grandma can't have these goodies!

This is how the hardware, a breadboard, ultrasonic sensor, tangle of wires, etc, was positioned inside

Early Draft

This was from an early attempt at this project, with the twist feature of infrared! It's soul, however, does live on in the final version.

Code

Project3Solo.py

Python
Using CircuitPython and Playground Express, this code reads the acceleration of the CPX and translates that into color hues, and changes the lights with movement. There is also an ultrasonic sensor, which can detect with something is within a specific range.
"""New Code, no Infrared, switch to right, is 'off', switch to the left, is 'on'. Neopixels will light up
colors based on acceleration. The sound will play based on the distance of hand"""

from adafruit_circuitplayground.express import cpx
import board
import adafruit_hcsr04  # sonar

# this creates the distance sensor as an object
sonar = adafruit_hcsr04.HCSR04(trigger_pin=board.A2, echo_pin=board.A1, timeout=0.1)

while True:
    # distance detected
    distance = int(sonar.distance)
    if not cpx.switch:
        # if switch is to the right, False (off) to the left, True (on)
        print("Off")
        cpx.pixels.fill(0, 0, 0)
        continue
    R = 0
    G = 0
    B = 0
    x, y, z = cpx.acceleration
    print((x, y, z))
    cpx.pixels.fill(((R + abs(int(x))), (G + abs(int(y))), (B + abs(int(z)))))

    if (distance >= 0) & (distance < 20):
        cpx.play_file("dip.wav")
    if (distance > 20) & (distance < 50):
        cpx.play_file("rise.wav")

Credits

Alex Beck
4 projects • 0 followers
Contact
Qing Wei
3 projects • 0 followers
Contact
Sunny
3 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.