Speaker pHAT and Neopixels

I’m trying to use a Speaker pHAT and a Neopixel Jewel with my Pi Zero. I can get them both to work individually, but it is when I try to combine them that I run into problems. My understanding (from some quick googling) is that this is due to them both trying to use PWM at the same time.

Is there any workaround for this? Any help would be greatly appreciated.

What I want to achieve in my project is:
A big dome button is lit by internally-fitted Neopixels
When the button is pressed an mp3 file is played and the Neopixels change colour.

speaker-phat requires the i2s interface - as any DAC. You should be able to use PWM1 to avoid conflict… see here: https://github.com/pimoroni/unicorn-hat/pull/82

Thanks for your response and for pointing me in the right direction. I’m pleased to report I have got it working now.

Using strandtest.py, I changed the NeoPixels configuration to read:

LED_PIN = 13 # GPIO pin connected to the pixels (must support PWM!).

and, crucially, passed the channel number by adding a 1 at the end of the line creating the NeoPixel object:

strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS,1)

This puts the NeoPixels on a separate PWM channel from the audio

GPIO pins 12 & 18 are on PWM Channel 0
GPIO pins 13 & 19 are on PWM Channel 1

1 Like