Serial comm question

Hi
I am working on a project and in troubleshooting it I think I found the issue but I don’t know what is causing it. I am using an arduino mega for this project.My code is shown below
int val;

void setup()
{

Serial.begin(9600);

}

void loop()
{
if (Serial.available() > 0) // wait for data
{
char val = Serial.read(); // reads the value of serial input
if ( 0 <= val < ‘10’) // bottom of speedometer
{
Serial.print(0);
}
else if (val >= ‘10’); // bottom of speedometer to servo endpoint
{
Serial.print(val);
}
/else if (val < ‘94’); // servo endpoint
{
Serial.println(180);
}
/
}
}
The problem I am having is that when I put a number into the serial monitor, 35 for instance, it prints the number 03050 instead of 35. What could cause this?
Thanks
Tanner

This reads one character at a time

char val = Serial.read();  // reads the value of serial input

This is trying to compare against 2 characters, it’s true every time

      if ( 0 <= val < '10') // bottom of speedometer
      {
        Serial.print(0);
      }

To reiterate that, you can't get "10" in one read. That's two separate characters, a '1' and a '0'.

Also note that single quotes are for single characters only. You can't put anything in single quotes that you can't type with one single stroke on your keyboard.

Have a look at the examples in Serial Input Basics. They are simple and reliable.

...R