Help with code

Hi guys, im new to arduino and i have to do a code where someone will write a grade and the serial will tell if the grade is enough to pass, but the code needs to have if and else, but the code is just telling that the grade isnt enough to pass, even if i type a number like 10.

void setup() {
Serial.begin(9600);

}

char rx_byte = 0;

void loop() {

if (Serial.available() > 0) {
rx_byte = Serial.read();

if (rx_byte <= 5,9)
{
Serial.println(“Did not pass”);
}else if (rx_byte >= 6)
Serial.println(“Has passed”);

}
}

You need to read up about data types. A byte cannot have a decimal value and Serial.read() only reads a single byte.

Have a look at Serial Input Basics and especially the parse example. Also look at the user data input part in Planning and Implementing a Program

...R

So what i can use to substitute the Serial.read? thanks

Why do you want to substitute it for anything?
Have you read Robin2's serial input basics excellent tutorial?

Or you could read the manual:
https://www.arduino.cc/en/Serial/ParseFloat

AWOL:
Why do you want to substitute it for anything?
Have you read Robin2's serial input basics excellent tutorial?

Because Serial.read() can only read a single byte

Im reading it, but i dont have much time so it will take some time

aarg:
Or you could read the manual:
Serial.parseFloat() - Arduino Reference

I'll read it, thanks

pedroharzer:
Because Serial.read() can only read a single byte

Im reading it, but i dont have much time so it will take some time

You can't rush quality and understanding. Sorry.

AWOL:
You can't rush quality and understanding. Sorry.

Aw shucks ... thanks.. I must keep a copy of this :slight_smile:

...R

@AWOL

That is today's tops.

Karma++