Hello, I've been working on this problem for a while. The required functionality of my project is to play a song, while also animating an LED strip based on values from another file (in this case it's currently a CSV).
I am using an Arduino Nano (because of price, size) with a Micro SD Module and a WS2812B LED strip.
I am able to animate the LEDs and play a song with separate programs, but combining them into a single one that plays them both in sync is proving to be the hardest challenge.
The current state is that I am using FastLED to send data to the lights and TMRpcm to play the audio. I've found these two libraries don't play well together because FastLED (or the LED strip) requires the data to be sent in strict timing, while TMRpcm, which plays the audio requires the use of timer interrupts. Timer interrupts break the LED data timing, causing the LEDs to not light up (as I understand it).
The LED part of the program has to read at least 150 bytes of data every 50ms to load the data for the LEDs without interrupting the audio. This actually requires opening two files at once from the SD card (audio + LED data), which does seem to work, but it's just sending that data to the outputs (a speaker and the LED strip) that is more complicated.
Is there a way to play audio and animate LEDs at the same time from the Arduino nano?
More specifically: can I rework the LED animation stuff to work with interrupts (a different library, or different type of LED)? is there a library that will work with this? Or is there a way to play WAV files without interrupts?
I've looked for other solutions, it seems playing audio without a DAC (digital analog converter?) pin is preferred, but it's not available on the nano. It's possible to use the DF Player Mini, but because I am reading another file for the LED animations, I'd need a second micro SD card and module, which is not a good solution for my project's use case.
I am very new to the world of microcontrollers, but have lots of software development experience working on desktop/web applications. I find this stuff so interesting, but at times very frustrating.
I have scoured the forums for the solution to this problem but have had a hard time finding anything that will work in this case. The closest I've found is this: DFPlayer MP3 module - get data from SD Card | Hackaday.io but I am not sure it will work for my use case.