Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: driving NeoPixels and audio

  1. #1

    driving NeoPixels and audio

    in general, can I play wave files and drive NeoPixels at the same time? I would need to drive the audio in the background.
    Philip

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,206
    It depends on which library you use.

    If you use WS2812Serial or OctoWS2811, then yes. Those are non-blocking and do not interfere with audio processing.

    If you use Adafruit_NeoPixel, then no. That library blocks interrupts. It can only drive a very short strip before it blocks too much and disrupts audio. Then good news is WS2812Serial implements API compatibility with Adafruit_NeoPixel, so if you've already written code using Adafruit's blocking library, usually it's pretty easy to switch to non-blocking WS2812Serial.

    If you use FastLED, then the answer depends on which of FastLED's drivers your code uses. The default WS2812 driver is similar to Adafruit's library. But FastLED has drivers which use WS2812Serial and OctoWS2811. So if you use those drivers, you can have the audio friendly non-blocking behavior and also leverage all the fancy color and rendering features of FastLED.

    No matter what you do in software, you should consider the hardware issue of ground loop noise from the beginning. If you power the LEDs from an earth grounded power supply, and you transmit audio to an amplifier or other gear which is earth grounded, you'll almost certainly get ground loop noise. It's a general audio issue, not specific to Teensy or NeoPixel, and you can find lots of info online about audio ground loop noise. While planning grounding is best from the start, if you do run into problems where you hear funny noises corresponding to changes on the LEDs, sometimes this product can help.

    https://www.pjrc.com/store/audio_ground_isolator.html

  3. #3
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    117
    I use WS2812Serial to drive 15+ LEDs as indicator LEDs in modular synth modules. Im not playing .wav files but have other timing critical things to do which works absolutely flawless. To avoid noise issues i keep everything LED realted as far away as possible from audio components, route the LEDs on the top side while havinge a GND plane on the back and power the LEDs from the same +5V as the teensy, isolated by an inductor for the +5V from the modulars rails. I use a single common GND, see here: http://www.hottconsultants.com/techt...slots.html#top and here http://www.hottconsultants.com/techt...gnd-plane.html

    Besides this, a WS2812 LED is way to bright as an indicator light with a light pipe; when running a not RetinaBurning(tm) brightness you are pretty much limited to about 5% of the maximum brightness, thus the number of usefull colors is rather limited.

  4. #4
    I am making a Binary clock with alarm. i am using LED - RGB Addressable,(SPARKFUN COM-12986) WS2812 using the driver:Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);

    the audio is powered with 5volts and occasionally the file gets distorted on the reading. I will look for redoing the power and ground.
    I am going to switch to the WS2812Serial driver.
    The LEDs are behind a partial mirror on the glass. it does a High pitch /Low pith tone for the Hours so you can tell the time by listening to the four tone beeps.


    Click image for larger version. 

Name:	Binary Clock.jpg 
Views:	21 
Size:	72.3 KB 
ID:	24033

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •