如何一起在覆盆子上使用Neopixel灯和声音输出?
我正在制作一个节目来播放一首歌,同时点亮了45个LED Neopixel Strip。问题是,当我使用sudo运行代码时,声音不起作用(我使用soundwave usb来音频卡),但是灯光起作用(我使用单独的测试程序以简单的灯光尝试),另一方面当我使用(python3 test_light_led.py)在终端中运行程序时,声音有效,但现在灯不起作用。
有人从事这样的事情吗?我一直在寻找很多解决方案,但找不到解决方案。
这是我当前的代码。任何帮助都将被应用。
import os
import playsound
import neopixel
import board
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.color import AMBER
pixel_pin = board.D18
pixel_num = 45
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness = 1, auto_write = False)
pulse = Pulse(pixels, speed = 0.1, color = AMBER, period = 3)
while True:
playsound.playsound("Happy_Voice.wav")
pulse.animate()
I am working on a program to play a song and at the same time light up a 45 led Neopixel strip. The problem is when I am running the code using sudo the sound is not working (I am using a soundwave USB to audio sound card) but the lights work (i tried it using a separate test program for just lights) and on the other hand when I run the program without sudo in terminal using (python3 test_light_led.py) the sound works but now the lights don't work.
Has anyone worked on something like this? I have been searching a lot of places for a solution but couldn't find one.
THis is my current code. Any help would be appriciated.
import os
import playsound
import neopixel
import board
from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.color import AMBER
pixel_pin = board.D18
pixel_num = 45
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness = 1, auto_write = False)
pulse = Pulse(pixels, speed = 0.1, color = AMBER, period = 3)
while True:
playsound.playsound("Happy_Voice.wav")
pulse.animate()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论