Go Down

Topic: Serial comunication problem (Read 425 times) previous topic - next topic


Nov 14, 2012, 08:19 pm Last Edit: Nov 14, 2012, 08:22 pm by D0p3n1nja Reason: 1
I'm relatively new to Arduino, but I know this isn't supposed to happen... I'm testing my serial because I was getting false inputs when I'd type a serial phrase... I set up this echo script from online sources and any time I type 1 it returns a 1 like it should but also a -38 on the next line immediately after... The -38 becomes 10 if I don't include the subtraction

void setup()

void loop()
while (Serial.available() == 0);

int val = Serial.read() - '0';   /*<<<----- this subtraction changes the false value from -38 to 10 if it is not here.  */

Arduino UNO R3
HP touchsmart TM2 running win7 64bit


ASCII "line-feed" (LF) character has the decimal value 10
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up