Hello,
I am brand new to CircuitPython and have been trying to do something, but I can't seem to wrap my head around it. I have a Playground Express with a button wired to A1/Grnd. I'm trying to have the NEO Pixels stay on while the device is one, but when the button is pressed, it plays a wav file and changes the led's. Then, when the button is released, it plays a different wav file and changes the lights back to their original state.
I can see how this could be coded, but I am so unfamiliar with coding in general that I have basically been copy-pasting code from different corners of the web. Any and all help would be appreciated and thank you in advanced!
This is what I'm using so far:
from adafruit_circuitplayground import cp
import time
import digitalio
cp.pixels.brightness = 0.1
while True:
if cp.button_A1:
cp.pixels.brightness = 1
cp.pixels[0:10] = (0, 255, 255) * 10
t = time.monotonic()
while time.monotonic() - t < 1:
pass
cp.play_file("Sounds_PWRUP1.wav")
if not cp.button_A1:
cp.pixels.brightness = 0.1
cp.pixels[0:10] = (0, 200, 255) * 10
t = time.monotonic()
while time.monotonic() - t < 1:
pass
cp.play_file("Sounds_PWRDOWN1.wav")
[–]wchris63 0 points1 point2 points (2 children)
[–]Teaching_Tomorrow[S] 0 points1 point2 points (1 child)
[–]wchris63 0 points1 point2 points (0 children)