Hello everyone,
Today I want to programm as first step a Serial communication to the PC like that:
void setup()
{
Serial.begin(9600);
}void loop()
{
while (Serial.available()==0);
int val = Serial.read();
Serial.print(val);
}
Well, If I send a "1" via the seriell Monitor I get "4910" back.
If I send a "20" via the seriell Monitor I get "504810" back.
Why is the "10" always at the end?
As next step I tried the following code:
void setup()
{
Serial.begin(9600);
}void loop()
{
while (Serial.available()==0);
int val = Serial.read()-'0';
Serial.print(val);
}
Now, I send a "1" via the seriell Monitor I get "1-38" back.
When I send a "20" via the seriell Monitor I get "20-38" back.
What's that?
can someone explain that?
I want to tipe in "1" and get "1"...