is it possible to set delay time in arduino program through serial command??

hi every one !
in my program i need to set the delay time through serial command , i have made an example program for this as shown below

int led=4;
void setup() 
{
  Serial.begin(9600);  
  pinMode(led, OUTPUT);
}
void loop() 
{  
    if (Serial.available() > 0)                          
    {
      char data = Serial.read(); 
      Serial.println(data);
     
        Serial.println("turn on the accessory");
        digitalWrite(led, HIGH);
        delay(data);
        digitalWrite(led, LOW);  
      
     
}}

will anybody please tell me what sort of mistake i am making in this

data is chr type, not an integer
You will have to convert it.

https://learn.sparkfun.com/tutorials/data-types-in-arduino
http://www.arduino-hacks.com/converting-integer-to-character-vice-versa/

Also, you're only reading a single character from serial, so you'll only be getting the numbers 0 to 9 in data. Is it likely that you'll see your LED flash for somewhere between 1/1000th and less than 1/100th of a second?

Look at these two demos here and here which illustrate how to receive different types of data from the Serial monitor or from a PC program.

The Arduino code in both demos works with the Serial Monitor.

...R