update soundbox code and sounds
updating soundbox code and sounds
This commit is contained in:
parent
ad042d2498
commit
8de5b7a9fe
23 changed files with 10 additions and 8 deletions
18
CircuitPython_Sound_Box_2/code.py
Normal file → Executable file
18
CircuitPython_Sound_Box_2/code.py
Normal file → Executable file
|
|
@ -14,7 +14,7 @@ import keypad
|
|||
import adafruit_lis3dh
|
||||
|
||||
from rainbowio import colorwheel
|
||||
hue = 0
|
||||
|
||||
# enable external power pin
|
||||
# provides power to the external components
|
||||
external_power = DigitalInOut(board.EXTERNAL_POWER)
|
||||
|
|
@ -25,6 +25,10 @@ external_power.value = True
|
|||
num_pixels = 24
|
||||
pixels = neopixel.NeoPixel(board.EXTERNAL_NEOPIXELS, num_pixels, brightness=0.4, auto_write=True)
|
||||
|
||||
delta_hue = 256//num_pixels
|
||||
speed = 10 # higher numbers = faster rainbow spinning
|
||||
i=0
|
||||
|
||||
# external button
|
||||
switch = keypad.Keys((board.EXTERNAL_BUTTON,), value_when_pressed=False, pull=True)
|
||||
|
||||
|
|
@ -58,7 +62,6 @@ num_colors = len(color_wavs)
|
|||
num_shakes = len(shake_wavs)
|
||||
wav_index = 0
|
||||
|
||||
|
||||
def open_audio(num, wavs):
|
||||
n = wavs[num]
|
||||
f = open(n, "rb")
|
||||
|
|
@ -83,7 +86,7 @@ while True:
|
|||
pixels.fill(color['color'])
|
||||
else:
|
||||
pass
|
||||
time.sleep(.7)
|
||||
time.sleep(1)
|
||||
pixels.fill((0, 0, 0))
|
||||
print('pressed')
|
||||
if event.released:
|
||||
|
|
@ -91,10 +94,9 @@ while True:
|
|||
if lis3dh.shake(shake_threshold=12):
|
||||
wave, wave_name = open_audio(random.randint(0, num_shakes - 1), shake_wavs)
|
||||
audio.play(wave)
|
||||
for i in range(num_pixels):
|
||||
pixels[i] = colorwheel(hue)
|
||||
hue = (hue + 30) % 256
|
||||
print(hue)
|
||||
time.sleep(.7)
|
||||
for l in range(len(pixels)):
|
||||
pixels[l] = colorwheel( int(i*speed + l * delta_hue) % 255 )
|
||||
pixels.show()
|
||||
time.sleep(1)
|
||||
pixels.fill((0, 0, 0))
|
||||
print('shake')
|
||||
|
|
|
|||
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/AQUA color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/AQUA color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/BLUE color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/BLUE color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/GREEN color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/GREEN color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/ORANGE color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/ORANGE color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/PINK color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/PINK color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/PURPLE color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/PURPLE color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/RED color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/RED color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE adabot.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE adabot.wav
Executable file
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE excellent.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE excellent.wav
Executable file
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE what.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/SHAKE what.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/WHITE color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/WHITE color.wav
Executable file
Binary file not shown.
Binary file not shown.
BIN
CircuitPython_Sound_Box_2/wavs/YELLOW color.wav
Executable file
BIN
CircuitPython_Sound_Box_2/wavs/YELLOW color.wav
Executable file
Binary file not shown.
Loading…
Reference in a new issue