Timer with User Input

Hello!

I'm currently working on a small project to learn how to use my arduino better! Basically, I ask if the user wants the light on or off, and if they say on, I ask for how many seconds, and the arduino will then light the led for that amount and then turn off. However, the time input is not working for me. Attached is my code. Please help!

char incomingByte; // for incoming serial data
int incomingtime;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
Serial.print("Ready! Enter h for on and enter l for off\n");

}
// RECEIVING VARIABLES TO CONTROL LIGHTS
void loop() {

// send data only when you receive data:
if (Serial.available() > 0)
{
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte);
if (incomingByte == 'h' || incomingByte == 'H')
{
Serial.print("How many seconds do you want it on for?:");
incomingtime = Serial.read();
Serial.print(incomingtime);
Serial.print("seconds");
}

else if (incomingByte == 'l' || incomingByte == 'L')
{
Serial.print("Light off!\n");
}
else
{
Serial.print("Invalid Entry!\n");
}

}

// LIGHT CONTROL

if (incomingByte == 'h' || incomingByte == 'H')
{
digitalWrite(13, HIGH);
delay(incomingtime*100);
digitalWrite(13, LOW);
}

else if (incomingByte == 'l' || incomingByte == 'L')
{
digitalWrite(13, LOW);
}

else
{
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13,HIGH);
delay(100);
digitalWrite(13, LOW);

}

}

timeronoff_take2.ino (1.75 KB)

          Serial.print("How many seconds do you want it on for?:");
          incomingtime = Serial.read();
        Serial.print(incomingtime);
        Serial.print("seconds");

How long are you waiting for the input? At 9600 baud, low long does it take for those 40 characters to get clocked out? How long does it take for the user's 1 byte answer to return?

You have a LOT to learn about how asynchronous communications work. Start here:
http://forum.arduino.cc/index.php?topic=396450.0

How many milliseconds in one second? Hint: Not 100.