So I am trying to make my room made auto in a way. I am trying to hook an IR remote to IR sensor. The problem isn't in the wiring or remote. So here is my code:
#include <IRremote.h>
#include <FastLED.h>
#define NUM_LEDS 60
#define DATA_PIN 7
#define COLOR_ORDER GRB
#define LED_TYPE WS2812B
int og = 0;
int ledspeed=1;
uint8_t max_bright = 64;
CRGB leds[NUM_LEDS];
int IRpin = 11;
int LED = 13;
IRrecv irrecv(IRpin);
decode_results results;
boolean LEDon = true; // initializing LEDon as true
void setup()
{
delay(100);
irrecv.enableIRIn(); // Start the receiver
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC);
irrecv.resume();
}
switch(results.value)
{
case 16:
{
digitalWrite(LED,HIGH);
}
break;
case 2064:
{
digitalWrite(LED,LOW);
}
break;
default:
fill_rainbow ( leds,NUM_LEDS,og,10); // These 3 lines make my led strip work
FastLED.show();//These 3 lines make my led strip work
og++; //These 3 lines make my led strip work
break;
}
}
Now what this does is turn on an led off and on when I press the keys 1 and 2 on my remote. The ir number for 1 is 16, and The ir number for 2 is 2064, obviously. The code works perfectly without the 3 lines "These 3 lines make my led strip work", it lets me turn the led on and off. But when those 3 lines are put into the code in any position or order the ir sensor just falls flat. So instead of giving me 16 when I press '1' it gives me a 7 digit number that is completely random. What do I do to fix this, thanks for reading. Please help!