char msg[80];  // array to store incoming characters
int idx = 0;   // index into array
int ledPins[] = {15, 2, 4, 5};
int numLeds = 4;
int i = 0;

char ch;

void setup() {
  // array of GPIO pins
  Serial.begin(115200);
  Serial.println("Program start ");


    for (i=0; i < numLeds; i++) {
    pinMode(ledPins[i], OUTPUT);
    }

 

  // Initialize each GPIO pin as an output and turn on the LED
  for (i = 3; i >= 0; i--) {
    digitalWrite(ledPins[i], LOW);
    delay(500);
  }

}

void loop() {
  // No code needed in the loop for this example
  // Check if data is available to read
  if (Serial.available() > 0) {
    ch = Serial.read();

    
    if (ch=='1')
    {
    digitalWrite(ledPins[0], HIGH);    
    Serial.println("key 1 pressed");
    }

    if (ch=='2')
    {
      digitalWrite(ledPins[1], HIGH);  
      Serial.println("key 2 pressed");
    }
    
    if (ch=='3')
    {
      digitalWrite(ledPins[2], HIGH);  
      Serial.println("key 3 pressed");
    }

    if (ch=='4')
    {
      digitalWrite(ledPins[3], HIGH);  
      Serial.println("key 4 pressed");
    }

       if (ch=='5')
    {
      for (i = 3; i >= 0; i--) {
        digitalWrite(ledPins[i], LOW);
        delay(500);
      }
    }

     if (ch=='6')
    {
      for (i = 3; i >= 0; i--) {
        digitalWrite(ledPins[i], HIGH);
        delay(500);
      }
    }


  }

}