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

CRGB leds[0];
int pin_receiver  = 2;   
int button_value = 0;
int bright = 20;

Servo myservo1;
IRrecv receiver(pin_receiver);

void setup()
{
  receiver.enableIRIn();   
  myservo1.attach(10);
  Serial.begin(9600); 

  FastLED.addLeds<NEOPIXEL, 3>(leds, 1);
}

void loop()
{
  if (receiver.decode()) 
  {
    translateIR();
    receiver.resume();  
  }
}

void translateIR()
{
  button_value = receiver.decodedIRData.command;

  if(button_value == 226)
  {
    Serial.println("Forward - Driver Door opens, Backward -  Driver Door Close, 1 - Lights ON in RED, 2 - Lights ON in Green, 3 - LIGHTS ON in Blue Color, 4 - Blinking LED,  Play - Control LED Glow, 9 - All stops");
  }

  if(button_value == 224)
  {
    myservo1.write(0);
    Serial.println("Door Closed");
  }

  if(button_value == 144)
  {
    myservo1.write(180);
    Serial.println("Door Open");
  }

  if(button_value == 48) 
  {
    leds[1] = CRGB::Red;
    FastLED.show();
  }

  if(button_value == 24)
  {
    leds[1] = CRGB::Green;
    FastLED.show();
  } 

  if(button_value == 122)
  {
    leds[1] = CRGB::Blue;  
    FastLED.show();
  }


  if(button_value == 16)
  {  
    for (int i = 0; i<=20; i++)
      {
        leds[1] = CRGB(0, 255, 221);
        FastLED.show();
        delay(50);
        leds[1] = CRGB(233, 255, 34);
        FastLED.show();
        delay(50);
        leds[1] = CRGB(255, 0, 191);
        FastLED.show();
        delay(50);
      }
  }

  if (button_value == 168)
  {
    bright = bright + 40;
    FastLED.setBrightness(bright);
    FastLED.show();
  }
 
   
  if(button_value == 162)
  {
    Serial.println("Application Stopped");
    myservo1.write(90);
    FastLED.clear(); 
    FastLED.show();
  }   

}