IR Sensor + 9m Animated LEDs

So i got a weird Problem and i cant think of something to work around it. I got 9m of WS2811 Led strips hooked up on a Arduino UNO R3. Now i attached a IR Sensor to it (3,3v , GND , Pin 7) that recieves the IR Signals sent from my Remote. Getting it to recieve the Signal itself is no Problem. But if i implement it into a Code that animates my Led Strip, i dont get Serial Prints to my Serial Monitor on COM3.

Following is my Code:

#include "FastLED.h"
#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long key_value = 0;

// Variables that remain constant
const byte pinData = A5; // Digital output pin to LED strip
//const byte pinClock = 3;  // Digital output pin to LED strip
const byte numLeds = 100; // Number of LEDs
struct CRGB leds[numLeds]; // Declare an array that stores each LED's data
DEFINE_GRADIENT_PALETTE( cw5 ) {
  0, 255, 60, 0, 
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  0, 255, 60, 0,
  235, 122, 35, 45,
  255, 169, 98, 90,
};
DEFINE_GRADIENT_PALETTE(auroraBorealis) {
    0,   0, 255,  28,
  128, 255,   3,  22,
  192, 247,   1,   9,
  255,   0, 255,  28
};
DEFINE_GRADIENT_PALETTE(cumulusClouds)
{
    0, 152, 164, 155,
   30, 139, 152, 140,
   64, 126, 141, 128,
   92,  80,  95,  82,
  107,  46,  59,  47,
  114,  74,  88,  71,
  123, 110, 124, 102,
  196,  46,  58,  39,
  255,  11,  18,   8
};
// Set the LED strip's overall brightness
byte totalBrightness = 255;
int value;
// Variables that can change
CRGBPalette16 activePalette = cw5; // Select a palette
byte paletteIndex = 0; // Current colour from the selected palette
// Total gradient palette colour transition time in minutes, with 10
// minutes = 2343.75 ms per transition step; 1 hour = 14062.5 ms
const byte transitionDuration = 3;
const byte noiseAmount = 2100; // Higher value = more granular noise
// The smaller the difference between the two values, the more subtle the
// noise's brightness variation will be
const byte minBrightness = 5;
const byte maxBrightness = 255;

void setup()
{
  FastLED.addLeds<WS2811, pinData, BRG>(leds, numLeds);
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}

void loop(){
{if (irrecv.decode(&results)){
 
        if (results.value == 0XFFFFFFFF)
          results.value = key_value;

        switch(results.value){
          case 0xCE1972FD: //ON
          Serial.println("ON");
          case 0xD4DD0381: //OFF
          Serial.println("OFF");
          case 0x8503705D: //Bightness +
          Serial.println("Brightness+");
          case 0xDEB0C861: //Brightness-
          Serial.println("Brightness-");
          case 0x9BA392C1: // WHite
          Serial.println("White");
          case 0xE85952E1: //Red
          Serial.println("Red");
          case 0x78CDA4DD: //Green
          Serial.println("Green");
          case 0xA2672345: //Blue
          Serial.println("Blue");
          case 0xDCC45BE1: //Flash
          Serial.println("Flash");
          case 0x374E8B9D: //Strobe
          Serial.println("Strobe");
          case 0xB9C07541: //Fade
          Serial.println("Fade");
          case 0xA7315F7D: //smooth
          Serial.println("Smooth");
          case 0xD3FD9A81: //R1
          Serial.println("R1")
          case 0x84044BBD: //R2
          Serial.println("R2");
          case 0xB0F9B3E1: //R3
          Serial.println("R3");
          case 0x9DE75E1D: //R4
          Serial.println("R4");
          case 0x6471EC7D: //G1
          Serial.println("G1");
          case 0x14789DB9: //G2
          Serial.println("G2");
          case 0x416E05DD: //G3
          Serial.println("G3");
          case 0xF794B621: //G4
          Serial.println("G4");
          case 0x9D52009D: //B1
          Serial.println("B1");
          case 0x3E121C21: //B2
          Serial.println("B2");
          case 0x6A844445: //B3
          Serial.println("B3");
          case 0x57F52E81: //B4
          Serial.println("B4");
        }
        key_value = results.value;
  }
}
  // Render the effect into the array leds
  paletteTransition();

  // Oscillate the overall brightness at a specified BPM, within a range
  FastLED.setBrightness(value);

  // Display all LED's data (= illuminate the LED strip)
  FastLED.show();

  irrecv.resume(); 
}

void paletteTransition()
{
  // Calculate gradient palette transition steps (in milliseconds)
  static const float interval = ((float)(transitionDuration * 60) / 256) * 10000000;

  // Declare a variable that stores the noise (= LED brightness) oscillation
  // speed
  static uint32_t dist;

  // Go through all LEDs in the leds array
  for (int i = 0; i < numLeds; i++)
  {

    // Calculate a Simplex Noise value
    int noise = inoise8(dist - i * noiseAmount, dist + i * noiseAmount) % 255;

    // Scale the noise value into a 0 - 255 brighntess value range
    byte brightness = map(noise, 0, 255, minBrightness, maxBrightness);

    // Write a colour fetched from the gradient palette, its brightness
    // modified by the noise, to the indexed LED
    leds[i] = ColorFromPalette(activePalette, paletteIndex, brightness, LINEARBLEND);
  }

  // Oscillate the noise's speed at a specified BPM, within a range
  dist += beatsin8(2, 2, 2);

  EVERY_N_MILLISECONDS(interval)
  {
    // Select the next colour
    if (paletteIndex < 255)
    {
      paletteIndex++;
    }

    // Wrap around back to zero at the end (= cycle through palette again)
    if (paletteIndex == 255)
    {
      paletteIndex = 0;
    }
  }
}

I want to remove the Serial Print part later and replace them with certain Actions. So i can controll Brightness and Color and switch it on and off via Remote.

Could it be that the “Time Window” in where the Arudino could possibly recieve a Signal (via the if (irrecv.decode(&results)) part) is too small and the Signal isnt getting picked up? Cause the Code is too Long ?

(The Code isnt done since i Need to “Connect” the functions like the Case block with each function i Need to add (Like Brightness , Color and stuff. But i first wanna make sure it recieves the Signals before continuing to write this Code and replace stuff)

EDIT:

I noticed that the Signals are somehow getting picked up, but it doesnt run any function other than “irrecv.blink13(true);”

I tried Building up the Code from Nothing and see what function might cause it to not Print the Responds into Serial Monitor. It stops Responding over Serial at FastLed.show();

Combining ws2811 signal & IR reception on an UNO is a problem. I will simply put it like this !
It probably can be done, but the issue is as follows. The ws2811 signal is send as a bit-banged signal that requires interrupts to be turned 'off' and the IR reception needs them turned 'on'
Every time that the signal is send they are turned off for the time it takes to send the signal (at 800khz for 24-bit per LED) that does not only mean that no reception is available during that time, but that any reception in progress is going to be 'broken' into 2 parts.
There are a few options. In my opinion the best is to switch to a board that can send ws2811 signal via a DMA mode like an ESP. That can be made to work 100% reliable.
You can of course, increase the time in between calls to .show() to improve your chances but no reliable system can be created in that way unless you actually stop the animation and wait for a valid IR reception. Though if you have wait times of up to 35ms, you will have something decent probably.
Or you can let the ws2811 and the IR be handle by different boards and let them communicate via Serial. You can have 100% reliable hwSerial reception while sending WS2811 signal if you have some time in between show() calls.

Also really your animation needs to be 'non-blocking' in nature, your primary concern is the reception of the IR-signal.
We could have a look into the IR library and see if it is possible to use the UART for reception, that could work.

UART …… Hmm didnt hear of that before gotta look it up what it is and it does.

Yea i thought of something to “increase the Time WIndow” by making it wait for Input for a few Moments. Since i got 100 Leds it Needs to write it could be a bit tricky tho.

Would a simple delay(1000); work behind the case lines? or do i Need other functions ? Im still Kind of new obviously ^^’

Thanks for the Infos

EDIT:

Looked it up. UART = Rx /Tx Pins of the Arduino and used for communication or something. But would it Change much? Interrupts would still be disabled while writing Leds would it? Or is the UART capable of Always “listen” to Input? I may likely misunderstand some stuff here.

How do i read the Tx pin in the Code? just like DigitalRead(0) ?

or do i just do
const int RECV_PIN = 0; ?

Edit 2:

I just Read that theres so called “Interrupt Pins” (2, 3 on Arduino Uno) That can trigger a function directly “Like a push notification on you phone”. Is this a Option or will the FastLed.show() still disable the Interrupt?

Yea i thought of something to "increase the Time WIndow" by making it wait for Input for a few Moments. Since i got 100 Leds it Needs to write it could be a bit tricky tho.

i thought you had 90 leds, anyway sending a signal to them would take a few ms should be ok

Would a simple delay(1000); work behind the case lines?

  FastLED.show();
  irrecv.resume();
  delay(35);
}

This would be the spot to put it, and waiting for a whole second will reduce the framerate of the ledstrip to much, try 35ms first.

But would it Change much? Interrupts would still be disabled while writing Leds would it? Or is the UART capable of Always "listen" to Input?

Yes interrupts would still be disabled, but the UART can receive a whole byte in the background before it sets it's interrupt flag (which then triggers the ISR that transfers this byte into memory) The IR receive system uses a timing interrupt which tests every bit individually. Depending on the transmission protocol and speed it is very possible that you can receive 100% reliable, but it will mean a complete re-write of the library, it is far from plug and play.

How do i read the Tx pin in the Code? just like DigitalRead(0) ?
or do i just do
const int RECV_PIN = 0; ?

You should be reading the RX pin, but again it should be a modification to the library, since we would not 'just read the rx-pin' but rather let the UART read the pin and read the byte from it's buffer.

Is this a Option or will the FastLed.show() still disable the Interrupt?

FastLed.show() still disables the interrupts, it won't work.

so delay(35) (Tested with 35, 65, 350 , 200, 500) rarely picks up the Signal and therefore isnt a Option i guess.
The Signal gets picked up if numLeds = <10

So how do i do this UART Thing? I got plenty of Time to read through any tutorials and Infos, but i dont know where to start.

I dont quite Understand “before it sets it’s interrupt flag (which then triggers the ISR that transfers this byte into memory)”
So the IR sends its Signal to Rx and the Rx saves one Byte to some Kind of “buffer” and this Byte can be read from there.

The OnBoard Indicator LED that is Setup via the Blink line in Void Setup is 100% reliable and Always responding even with Holding a button pressed. Interesting that the Blink doesnt Need Interrupts.

Couldnt i do DgitalRead(0) and somehow "DigitalRead(“UART Buffer”) and use the HEX it gives for the cases ?

Sadly there rly is no Pin that has top priority and just stops Fastled.show() and first triggers any functions attached to it before goin on in loop() i guess.

Edit:
Also the UART Buffer is just a single Byte. The HEX that is being recieved is more than that tho (1 Character is 4 bits) so the Buffer would Need 4 Bytes wouldnt it? Cause 3/4 of the HEX wouldnt be recieved/get lost. I think im wrong here tho.

And the Buffer Needs to be moved to the Memory every 104µs before its lost. If i stay at 9600 Baud Rate. Dont know if i can / should Change that. A Baud rate of 300 could increase the time to 333µs for it to move the Byte to Memory. And since its 4bytes just gettin recieved here and there it doesnt look like a Problem for a low baud rate.

So how do i do this UART Thing? I got plenty of Time to read through any tutorials and Infos, but i dont know where to start.

It is not the way to go. The IR signal is not actually send in any standard Serial protocol, but rather seems to be working with 'tick' (or pulses as you like) This can be received on the UART (particularly since the ticks appear to be 50us in length, which comes down to a baud-rate of about 20000, so not too fast) but it will mean a rather complex re-writing of the library. We shou;d focus on the other 2 options. Either using an extra processor (which could be as small as an ATtiny85 or 2313 as long as it has hwSerial) to receive the IR or the most straightforward to use an ESP8266 (an ESP-01 would do) to do the whole thing. The latter would be my choice if i was confronted with the issue myself. There is a library for receive IR on an ESP (the timers on an ESP are different, so a different library would be needed) And as far as i know FastLED does have a DMA mode for ESP, though i always use Makuna/Neopixelbus where DMA mode is the default for ESP.

Thanks for all the Infos ^^

Edit:

I changed the IR reciever Pin to 2 (InterruptPin)

and added a delay(35); before FastLED.show(); and a delay(350); after it. It now reacts to 80% of it while it also writes 100 Leds. The Animation seems to be gone (cuz of the delays) but imma test more. Since (without the IR stuff) the Animation is rather slow it may look like ist "stopped" now. I might try to increase Animation Speed to compensate for the low fps.

Thanks for Help again ^^

You're welcome, well anyway if you want a single board solution for your project that does have a decent framerate, get an ESP-01, they are quite cheap and will do the job for you.