Arduino Serial communication troubles
It looks like you're confusing the ASCII values of the numbers with the numbers themselves.

If you send a '1' character over the serial port, you're actually sending the byte 49 (0x31). This is why you're seeing the invalid 49.

Either change your code to understand ASCII, or send the raw bytes instead of ASCII digits.