Boston Tribute

by nijjar in Circuits > Art

177 Views, 1 Favorites, 0 Comments

Boston Tribute

IMG_6302.jpeg
IMG_6304.jpeg
IMG_6303.jpeg

This is an interactive tribute to Boston. It lights up and plays iconic Boston songs when you move near it.

Supplies

45d954114c2910cb53d899cd8f9d5118.png

1/8 and 1/4 inch birch wood

Laser Cutter

Wires

Adabluefruit CPB

Speaker

Proximity Sensor

LED Light strip

Hot Glue

Cardboard

Battery pack

Tape

45d954114c2910cb53d899cd8f9d5118.png

establish an image to utilize in this project, and prepare it in Adobe illustrator.

Laser cut the design along with a corresponding stand. When designing the stand be sure to carefully choose the angle at which you would like it to stand.

IMG_6304.jpeg

Glue the LEDs into the back and solder wire from them into the CPB and add alligator clips for convenience.


Hot glue speaker to back and attach wiring

IMG_6303.jpeg

Align the proximity sensor to be positioned where you would like and hot glue it to that position.

upload this code to the CPB:

# import lines needed to play sound files


import board, digitalio, time, neopixel, random

from audiopwmio import PWMAudioOut as AudioOut

from audiocore import WaveFile


from adafruit_apds9960.apds9960 import APDS9960

i2c = board.I2C()

multi_sensor = APDS9960(i2c)

multi_sensor.enable_proximity = True


# Get a reading - 0 is far away, 255 is very close

reading = multi_sensor.proximity


# Speaker


speaker = digitalio.DigitalInOut(board.SPEAKER_ENABLE)

speaker.direction = digitalio.Direction.OUTPUT

speaker.value = True

audio = AudioOut(board.AUDIO)



path = "sounds/"

filename="untitled.wav"

# play_sound function - pass in the FULL NAME of file to play

def play_sound(filename, anim):

 with open(path + filename, "rb") as wave_file:

  wave = WaveFile(wave_file)

  audio.play(wave)

  while audio.playing:

   anim.animate()


# Button


# Use Pull.UP for external buttons wired to ground

# button = digitalio.DigitalInOut(board.A4) # Wired to pin GP15

# button.switch_to_input(pull=digitalio.Pull.UP)


from adafruit_led_animation.animation.blink import Blink

from adafruit_led_animation.animation.colorcycle import ColorCycle

from adafruit_led_animation.animation.chase import Chase

from adafruit_led_animation.animation.comet import Comet

from adafruit_led_animation.animation.pulse import Pulse

from adafruit_led_animation.animation.sparkle import Sparkle

from adafruit_led_animation.animation.sparklepulse import SparklePulse

from adafruit_led_animation.animation.rainbow import Rainbow

from adafruit_led_animation.animation.rainbowchase import RainbowChase

from adafruit_led_animation.sequence import AnimationSequence


from adafruit_led_animation.color import (

 AMBER, # (255, 100, 0)

 AQUA, # (50, 255, 255)

 BLACK, # OFF (0, 0, 0)

 BLUE, # (0, 0, 255)

 CYAN, # (0, 255, 255)

 GOLD, # (255, 222, 30)

 GREEN, # (0, 255, 0)

 JADE, # (0, 255, 40)

 MAGENTA, # (255, 0, 20)

 OLD_LACE, # (253, 245, 230)


 ORANGE, # (255, 40, 0)


 PINK, # (242, 90, 255)


 PURPLE, # (180, 0, 255)


 RED, # (255, 0, 0)


 TEAL, # (0, 255, 120)


 WHITE, # (255, 255, 255)


 YELLOW, # (255, 150, 0)


 RAINBOW, # a list of colors to cycle through


 # RAINBOW is RED, ORANGE, YELLOW, GREEN, BLUE, and PURPLE ((255, 0, 0), (255, 40, 0), (255, 150, 0), (0, 255, 0), (0, 0, 255), (180, 0, 255))


)




pixels_pin = board.NEOPIXEL


pixels_num_of_lights = 23


pixels = neopixel.NeoPixel(pixels_pin, pixels_num_of_lights, brightness=0.5)




strip_pin = board.A1


strip_num_of_lights = int(23)


strip = neopixel.NeoPixel(strip_pin, strip_num_of_lights, brightness=0.5, auto_write=True)




INDIGO = (63, 0, 255)

VIOLET = (127, 0, 255)

OFF = 0, 0, 0

pause = 0.3

mycolors = [


 RED,


 MAGENTA,


 ORANGE,


 YELLOW,


 GREEN,


 JADE,


 BLUE,


 INDIGO,


 VIOLET,


 PURPLE,


 OFF,


]


blink = Blink(pixels, speed=0.5, color=JADE)

blink_strip = Blink(strip, speed=0.5, color=AMBER)


colorcycle = ColorCycle(pixels, 0.1, colors=mycolors)

colorcycle_strip = ColorCycle(strip, 0.1, colors=mycolors)


chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)

chase_strip = Chase(strip, speed=0.1, color=WHITE, size=1, spacing=1)


comet = Comet(pixels, speed=0.05, color=RED, tail_length=10, bounce=True)

comet_strip = Comet(

 strip, speed=0.05, color=RED, tail_length=int(strip_num_of_lights / 4), bounce=True

)


pulse = Pulse(pixels, speed=0.05, color=AMBER, period=2)

pulse_strip = Pulse(strip, speed=0.05, color=BLUE, period=2)


sparkle = Sparkle(pixels, speed=0.05, color=PURPLE)

sparkle_strip = Sparkle(strip, speed=0.05, color=PURPLE)


sparkle_pulse = SparklePulse(pixels, speed=0.05, period=5, color=BLUE)

sparkle_pulse_strip = SparklePulse(strip, speed=0.05, period=5, color=BLUE)


rainbow = Rainbow(pixels, speed=0.05, period=2)

rainbow_strip = Rainbow(strip, speed=0.05, period=2)


rainbow_chase = RainbowChase(pixels, speed=0.01, size=5, spacing=0, step=8)

rainbow_chase_strip = RainbowChase(strip, speed=0.01, size=5, spacing=0, step=8)


animations = AnimationSequence(

 blink,

 colorcycle,

 chase,

 comet,

 pulse,

 sparkle,

 sparkle_pulse,

 rainbow,

 rainbow_chase,

 advance_interval=5,

 auto_clear=True,

)


animations_strip = AnimationSequence(

 blink_strip,

 colorcycle_strip,

 chase_strip,

 comet_strip,

 pulse_strip,

 sparkle_strip,

 sparkle_pulse_strip,

 rainbow_strip,

 rainbow_chase_strip,

 advance_interval=5,

 auto_clear=True,

)


sounds = ["for-boston.wav", "shipping.wav"]

animations_random_list = [rainbow_strip, chase_strip, sparkle_pulse_strip, pulse_strip, comet_strip]


while True:

  q = 7

  reading = multi_sensor.proximity

  strip.show()

  if reading > 10:

    print("Person detected!")

    q = random.randint(0,3)

    print(q)

  if q == 0:

    play_sound(random.choice(sounds), random.choice(animations_random_list))

    strip.fill(BLACK)

    strip.show()

  elif q == 1:

    play_sound(random.choice(sounds), random.choice(animations_random_list))

    strip.fill(BLACK)

    strip.show()

  elif q == 2:

    play_sound(random.choice(sounds), random.choice(animations_random_list))

    strip.fill(BLACK)

    strip.show()

  elif q == 3:

    play_sound(random.choice(sounds), random.choice(animations_random_list))

    strip.fill(BLACK)

    strip.show()

   #for i in range(0,20,1):


    # strip.show()


   # w = int(random.randint(0,255))


   # print(w)


   # e = int(random.randint(0,255))


   # print(e)


   # r = int(random.randint(0,255))


   # print(r)


   # strip[i] =((w,e,r))


   # time.sleep(0.05)

 #else:

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

  #pixels.fill((0,0,0))

  # blink_strip.animate()

  # colorcycle.animate()

  # colorcycle_strip.animate()

  # chase.animate()

  # chase_strip.animate()

  # comet.animate()

  # comet_strip.animate()

  # pulse.animate()

  # pulse_strip.animate()

  # sparkle.animate()

  # sparkle_strip.animate()

  # sparkle_pulse.animate()

  # sparkle_pulse_strip.animate()

  # rainbow.animate()

  # rainbow_strip.animate()

  # rainbow_chase.animate()

  # rainbow_chase_strip.animate()

  # animations.animate()

Boston Tribute