Stuck with State problem (Urgent!!!) (Simple!)

Hello Forum-goers,
I’m writing some code for a scoreboard controller and the entire code is basically if (state == ‘x’) then do ‘this’. My problem is though, I am using numbers for the state ex: if (state == ‘1’). Numbers 1-9 work fine but as soon as I use ‘10’ it stops working. Can the arduino only use numbers 1-9? I have 16 statements to do and I’ve only gotten 9 to work. What do I need to do? I included the code in the attachments. I know its not very efficient but I’m very new to this.

Thanks!

Scoreboard.ino (3.54 KB)

This line    state = Serial.read();reads one character from the serial buffer and assigns it to the variable state. One thing that’s certain is that it will never be two characters long, and it takes two characters to represent 10.

You might believe that you’re assigning the numbers 1 through 9 to state, but you’re actually assigning the characters ‘1’ through ‘9’. To fix it, you might consider developing a way to fetch a C string from the serial terminal, and convert to an integer using atoi(). You might read characters until you get a carriage return or linefeed, convert the result to integer, and assign it to state.

I don't really know what any of that means. You lost me after "fetch a C string.." I'm really new to this so can you please explain a little more?

Use the characters 'A' to 'F' (or even 'Z') for your states instead of the characters '1' to '9'. If you don't know what that means, look up "ascii character set".

jremington: Use the characters 'A' to 'F' (or even 'Z') for your states instead of the characters '1' to '9'. If you don't know what that means, look up "ascii character set".

That worked! Thank you so much!