So I’ve been working on a setup that involves taking MIDI input and using that to control an LED strip (currently working with an APA102 strip), but am having some trouble figuring out how to get the LEDs to display more synchronously.
As a test, I’ve setup a simplified test where I have each MIDI note corresponding to a single LED on the strip (rather than some of the more complex wave functions I’ve been using) - note value 0 turns on/off LED position 0, value 1 controls LED position 1, etc.
When I have the loop run FastLED.show() by itself, the strip displays all the LEDs correctly (i.e. no MIDI messages dropped), up to 25 notes - anything more than that, and MIDI messages get dropped (i.e. an LED not turning on). Problem is, there is a noticeable delay between each note, and so you can see each LED light up one by one in order.
As an experiment, I tried putting a conditional around the show function:
if (!MIDI.read()) { FastLED.show(); }
…which I know is not ideal, but it looks like I do get a more synchronous result. There’s still a slight delay between LEDs lighting up, but it’s definitely much better than before. The problem now is that random MIDI messages get missed regularly. Furthermore, the Arduino will crash occasionally, which I still have yet to figure out the reason why.
It seems like without the “if” statement, the Arduino is at least still reading all the MIDI correctly and queuing the data up, but is taking time to display everything. Having the “if” statement for some reason makes the output side faster, but in turn other problems get introduced.
(Side note - I know having a million “if” statements is not ideal, but I’ve tried messing around with using “switch/case” statements instead and still seem to get the same issue, so it doesn’t seem to be a huge factor here.)
Furthermore, based on a suggestion from the Arduino forums, I tried adding an extra “shown” boolean:
if (!MIDI.read() && ! shown) { FastLED.show(); shown = true}
…which resulted in no MIDI notes missed, and is definitely speedier than FastLED.show(), but still has a visible delay. On top of that, this doesn’t really work if I want to use any functions that require regular updating of the LEDs to display the animation sequences correctly.
Any ideas??


