problem serial port

user can select the buzzer to buzz at some interval
user ask for the interval such as 1 sec, 2 sec,…,up to 5 sec
if user enter 0 or >6, must inform the user that it is not allow and re-enter the interval
problem is user interval such as 1 sec, 2 sec,…,up to 5 sec

lat say 1 sec, then on 1 sec buzzer and off 1 sec buzzer

2 sec, then on 2 sec buzzer and off 2 sec buzzer

int buzzer = 13;                 // buzzer connected to digital pin 13
int incomingByte = 0;

void setup()
{
  pinMode(buzzer, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop()
{ 
  if(Serial.available() >0)
  {
  incomingByte = Serial.read();

  if (incomingByte <= 0)
  {
    Serial.print ("invalid interval re-enter the interval");
    
  }
  else if (incomingByte > 6)
  {
    Serial.print (" interval is too high re-enter the interval");
    
  }
  else
 {
  digitalWrite(buzzer, HIGH);   // sets the buzzer on
  delay(1000);                  // waits for a second
  digitalWrite(buzzer, LOW);    // sets the buzzer off
  delay(1000);                  // waits for a second
}
}
}

check your ascii table look up, a byte with a value of 6 isnt the ascii character ‘6’

http://www.asciitable.com/

if your looking for the characters 1-5 check for ‘1’, or ‘2’, or ‘3’,‘4’,or ‘5’… Or the ASCII code for the character your looking for 49 to 53

if (48 < byte < 54) or if (0 < (byte-48) <6)

Debugging is an essential part of successful computer programming.

When something does not work as expected you MUST assume that the computer is actually doing what you told it to do. You just did not tell it to do what you wanted to happen.

So you need to figure out what is actually happening so you can make an appropriate change to your program.

In this case (in most cases) a good place to start is to insert Serial.println() statements so you can see the value of the variables the computer is actually working with (rather than the values you think it is using).

For example

Serial.println(incomingByte);

…R