jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.76k stars 616 forks source link

I2s audio output with PWM led strip? #459

Closed hyansuper closed 3 years ago

hyansuper commented 3 years ago

I don't fully understand the readme about PWM and PCM. Will they interfere each other if I want to use them both. I have a pi zero w. Can I use the I2S MAX98357 amplifier (pin18) to output audio and PWM (pin13) to control led strip? would they work at the same time?

thank you~

lmeysel commented 3 years ago

I got nearly the same setup, Pi Zero W, i2s amplifier and ws2811 LED strip and got things running (I prefer using SPI, as it allows controlling the LEDs as non-root user, but also tested it with PWM).

Altough the song is playing "recognizable" while the LEDs are running, the problem is a crackling in sound appears every time I call render(). Unfortunately I did not find out why...

hyansuper commented 3 years ago

Does the crack sound appear with SPI or PWM? I didn't test SPI coz it's already in use,but PWM seems no problem

lmeysel commented 3 years ago

It appeared in both, PWM and SPI. I thought it could have to do with mem speed or CPU, but it actually was because of the power-supply 🤦‍♂️

I used the same supply for LED and Amplifier (in parallel). While the LEDs changing the color, the load seems to be a bit higher, which makes the supply kind of "slightly instable", which resulted in a fluctuating bias point of the sound amplifier which again results in the crackling noise.