My device is a Pi Zero 2 W. The OS is Raspberry PI OS (64-bit), Bookworm. I followed the instructions here from butchkemper:viewtopic.php?t=359240 to ensure that there was enough memory to update the entire system. I've checked that all of the libraries and firmware are updated.post the os your using (desktop/lite/32/64) &
your script your trying to run.
Here's an example of the code I'm attempting to run:
Code:
import boardimport neopixelfrom gpiozero import Button#Play sounddef playsound(): sound = pygame.mixer.Sound('Media/sound_effect.wav') sound.play() time.sleep(4)if __name__ == '__main__': pygame.init() button = Button(17) pixels = neopixel.NeoPixel(board.D18, 10, brightness = 255) #Set the NeoPixels to blue by default pixels.fill((0, 0, 255)) while True: if button.is_pressed: playsound() pixels.fill((255, 0, 0))
I've tried four different cases.
If I run the script as normal (python3 script.py), I get the above error where I need sudo in order for NeoPixels to run.
If I run the script as sudo (sudo python3 script.py), there are no runtime errors, and the NeoPixels light up as intended. In fact, when I the press the button, you can tell it triggers the time.sleep(4) before switching the colors. This leads me to believe it's attempting to output audio but perhaps to a source that isn't the bluetooth speaker.
This is the part that leads me to believe it has something to do with sudo not recognizing the bluetooth speaker.
If I take out the neopixels part altogether, and run the code normally (python3 script.py) the sound plays over the speaker after the button hits as intended.
If I take out the neopixels part, and run the code as sudo (sudo python3 script.py), then once again no sound gets output to the bluetooth speaker.
Statistics: Posted by buttmunky — Fri May 03, 2024 12:08 am