IR Receiver Gives Random Data

I know there are other topics on this issue (I believe they are the same issue), but I never found a solution that actually worked for me.

I have an LED strip project that works great by itself, but I want to use a remote control to be able to change settings, brightness, etc.

I am using the remote-receiver kit that comes with the ELEGOO project kit (nothing special). I put together a basic circuit with an Uno to print the values the receiver library decodes. I’m using Shirriff’s library, and by itself it works fine, spits out correct codes like I would expect. When I try to integrate it into my LED strip circuit, pressing a button gives a random code.

I’ve tried putting RC low pass filters in series with the power and data wires of the sensor. I tried 100ohm/100uF and 470ohm/10uF. Neither worked.

Heres my code:

#include <ir_Lego_PF_BitStreamEncoder.h>
#include <boarddefs.h>
#include <IRremoteInt.h>
#include <IRremote.h>

#include <FastLED.h>

#define NUM_LEDS 10
#define SIGNAL_PIN A5
#define MUSIC_OFF_PIN 2
#define AMBIENT_OFF_PIN 4

#define RECV_PIN 9
#define DATA_PIN 11

int highest = 0;
int highestResetTimer = 0;

int colorChangeTimer = 0;
int colorCounter = 0;
int direction = 1;

IRrecv irrecv(RECV_PIN);
decode_results results;
CRGB leds[NUM_LEDS];

void setup() {
  pinMode(SIGNAL_PIN, INPUT);
  pinMode(MUSIC_OFF_PIN, INPUT);
  pinMode(AMBIENT_OFF_PIN, INPUT);
  pinMode(DATA_PIN, OUTPUT);
  
  Serial.begin(9600);
  irrecv.enableIRIn();
  FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  if(irrecv.decode(&results)){
    Serial.println(results.value, HEX);
    irrecv.resume();
  }

  int musicOff = digitalRead(MUSIC_OFF_PIN);
  int ambientOff = digitalRead(AMBIENT_OFF_PIN);
  if(musicOff == LOW){
    highestResetTimer++;
    if(highestResetTimer >= 2000){ // few times per song?
      // reset highest after 5000 loops, prevents from getting to high
      // for some reason, causing gain calculation to not work
      highest = 0;
      highestResetTimer = 0;
    }
    int signal = map(analogRead(SIGNAL_PIN), 0, 1023, 0, 255);
    if(signal > highest){
      highest = signal;
    }
    // calculates correct gain regardless of range of signal
    int gain = 255 / highest;
    signal *= gain;
    signal = min(signal, 255); // just in case

    // serial plotter info
//    Serial.print(255);
//    Serial.print(" ");
//    Serial.print(signal);
//    Serial.print(" ");
//    Serial.print(highest);
//    Serial.print(" ");
//    Serial.println(0);

    for(int i = NUM_LEDS - 10; i < NUM_LEDS; i++){
      // multiply = flashing color; <= 1.00
      // add = ambient color; <= 16
    
      //      | is a bug, red and green are flipped
      //      V
      leds[i].g = signal * 0 + 0; // RED
      leds[i].r = signal * 0 + 0; // GREEN
      leds[i].b = signal * 1 + 0; // BLUE
    }
    FastLED.show();
  }else if(ambientOff == LOW){
    colorChangeTimer++;
    if(colorChangeTimer >= 40){
      colorChangeTimer = 0;
      colorCounter+= direction;
    }
    if(colorCounter >= 360 || colorCounter <= 0){
      direction *= -1;
    }
    for(int i = NUM_LEDS - 10; i < NUM_LEDS; i++){
      leds[i] = CHSV(colorCounter, 255, 255); 
    }
    FastLED.show();
  }
}

Circuit involves an audio processing section, a switching circuit, and the IR circuit all based around a Micro. I can provide more details if necessary.

I would very much appreciate any insight, this project is really cool to me and I’m trying to get it working as soon as possible.