char comparison on UNO

the following code works on Arduino Yun.

int ledPin = 13;
int ledState = HIGH;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
}

void loop() {
  while(Serial.available()){
    int inChar = Serial.read();
    Serial.write(inChar);
    if(inChar == '1'){
      ledState = HIGH;
    }
    if(inChar == '2'){
      ledState = LOW;
    }
  }
  digitalWrite(ledPin,ledState);
}

it's quite simple. but when i run it on an Arduino UNO, the led never goes off. in the serial monitor, i do see that arduino write back '1' or '2' or anything sent to it. but it just cannot go into the if() statement. really weird!

Works fine on my Nano and Uno, running Windows 7 and IDE 1.6.5

really really weird! I just find that if the binary format of the ASCII of the character contains even number of '1', it works. otherwise it cannot go into the if() statement.
e.g. if(inChar = '0') or if(inChar = '3') or if(inChar = 'P'), it can go into the if() statement.
'0': 00110000
'3': 00110011
'P': 01010000

and for other characters, it cannot work. such as:
'1': 00110001
'R': 01010010

Sounds like a serial parity bit problem. What are you using to send the characters to the Uno? The serial monitor in the Arduino IDE?

Any difference if you change the read statement to this?

char inChar = Serial.read();

I just find that if the binary format of the ASCII of the character contains even number of '1', it works

Big clue there.

int inChar = Serial.read() & 0x7f;
    Serial.write(inChar);
    if(inChar == '1'){

i'm such a fool! I set the parity to a wrong format! now it works.