如何一起在覆盆子上使用Neopixel灯和声音输出?

发布于 2025-01-27 13:32:54 字数 706 浏览 3 评论 0原文

我正在制作一个节目来播放一首歌,同时点亮了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文