Hi all, Back again, after my previous issue with FastLED and IRremote:

Hi all,

Back again, after my previous issue with FastLED and IRremote: https://plus.google.com/116290059563092929907/posts/fWzNiEeDEbP

I received some great help, and decided to get an additional microcontroller to dedicate to the IR processing, so that my Arduino could focus on handling the LED’s. In the meantime, I emulated the remote-control through a Serial connection to my laptop. This all worked fine.

Yesterday, I got my brand new Atmega328p to run the IR code, and all it needs to do is decode the signal and send a 32-bit value across the serial line to the Arduino, much like my laptop was doing before. Without calling the FastLED.show() function, everything works fine and the values are transmitted properly. However, when I uncomment the call that (indirectly) invokes FastLED.show(), the same problem that I had before arises: the values aren’t transmitted properly anymore.

My question to you: do you think it’s possible that the Serial connection is interfering with FastLED? It seems weird because the serial connection to my laptop worked just fine. My Mega2560 has multiple serial connections, and it didn’t help to switch to others. Would communicating over I2C help? I’ve tried setting this up, but ran into other issues (http://stackoverflow.com/questions/27705156/i2c-onreceive-handler-called-only-once).

Again, input of any kind will be much appreciated :slight_smile:

I seriously doubt that the serial connection is interfering. Last time I tested, my aalight and aainfra worked just fine at https://github.com/atuline/FastLED-Demos

I discovered that sending single bytes works fine. As soon as I try to reconstruct 4-byte integers on the receiving side, things get messed up. I restructured my code such that that isn’t necessary anymore. It’s not as pretty (less modular), but at least it works…

Because writing ws2812 data disables interrupts, you will lose serial data that is sent while the leds are being written. What you need to do is have some kind of a command header - and what you do is after calling show you flush the serial input buffer (while(Serial.available()) { Serial.read();}), then wait for the head sequence.