need help in my code

Robin2:
If you indent your code like this it makes it much easier to follow

#include <IRremote.h>

#define first_key 0xF7B04F
#define second_key 0xF7A05F
#define third_key 0x7609F
#define fourth_key 0xF710EF
int receiver_pin = 11;
int first_led_pin = 4;
int second_led_pin = 5;
int third_led_pin = 6;
int fourth_led_pin = 7;
int led[]{0,0,0,0,};
IRrecv receiver(receiver_pin);
decode_results output;

void setup() {
        // put your setup code here, to run once:
    Serial.begin(9600);
    receiver.enableIRIn();
    pinMode(first_led_pin, OUTPUT);
    pinMode(second_led_pin, OUTPUT);
    pinMode(third_led_pin, OUTPUT);
    pinMode(fourth_led_pin, OUTPUT);
}

void loop() {
        // put your main code here, to run repeatedly:
    if (receiver.decode(&output)){
        unsigned int value = output.value;
        switch(value) {
            case first_key:
                if(led[1]==1){
                    digitalWrite(first_led_pin,HIGH);
                    led[1] = 0;
                }
                else
                {
                    digitalWrite(second_led_pin,LOW);
                    digitalWrite(third_led_pin,LOW);
                    digitalWrite(fourth_led_pin,LOW);
                    led[1] = 1;
                }
                break;
            case second_key:
                if(led[2]==1)
                {
                    digitalWrite(second_led_pin,HIGH);
                    led[2] = 0;
                   
                }
                else
                {
                    digitalWrite(first_led_pin,LOW);
                    digitalWrite(third_led_pin,LOW);
                    digitalWrite(fourth_led_pin,LOW);
                    led[2] = 1;
                }
                break;
            case third_key:
                if(led[3] == 1)
                {
                    digitalWrite(third_led_pin, HIGH);
                    led[3] = 0;
                }
                else
                {
                    digitalWrite(first_led_pin,LOW);
                    digitalWrite(second_led_pin,LOW);
                    digitalWrite(fourth_led_pin,LOW);
                    led[3] = 1;
            }
                break;
            case fourth_key:

if(led[4] == 1) {
                    digitalWrite(fourth_led_pin, HIGH);
                    led[4] = 0;
                }
                else
                {
                digitalWrite(first_led_pin,LOW);
                    digitalWrite(second_led_pin,LOW);
                    digitalWrite(third_led_pin,LOW);
                led[4] = 1;
                }
                break;
        }
        Serial.println(value);
        receiver.resume();
    }
}



Use the Autoformat tool

You need to explain what the existing code does and where in that code you want to have the auto-off for the LEDS.

The demo [Several Things at a Time](http://forum.arduino.cc/index.php?topic=223286.0) illustrates the use of millis() to manage timing - it should give you ideas about how to achieve what you want.

...R

Thanxxx sir,

The code use for competition game. the game is any one pressing the button to turn led light. the led light is going to turn on for 4 second but other led light is off until 4 second finish....