Serial.read -38 ???

Hello,

Using the code below and typing a "2" in the Serial Monitor I get:

2
-38

Why is that?
I just want rxVal to be saved/set as "2" but it always drops to -38 afterwards.
If i type in 456, I get:

4
5
6
-38

Thanks a lot for your help!

 rxVal = 1;

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

void loop () 
{

if(Serial.available() > 0)
   {
    rxVal = Serial.read() -'0';
    Serial.println(rxVal);
   }  

}

'0' == 0x30 == 48

-38 + 48 = 10

You are getting a newline character at the end of the input line. If you are using the Serial Monitor window in the Arduino IDE you can select "No line ending" in the drop-down men at the bottom.

Ah thats it, Thank You!