arduino processing wrong values


I'm having troubles with arduino and processing. What I was trying to do, is to make arduino to send some values to processing, but the values I'm getting on arduino console and the values proccessing is printing are completely differend i.e. on arduino I get 18 on processing 49 56 13 10

processing code to receive data

if ( myPort.available() > 0) {  // If data is available,
    val =;  // read it and store it in val

arduino code

void loop() {
 int key = getIRKey();             //Fetch the key
 if (key != -1) {

Any suggestions :-/

Are both baud rates the same?

49 56

49 is ASCII '1' 56 is ASCII '8' 10 is ASCII Line Feed (LF) 13 is ASCII Carriage Return (CR)

So it is only sending ASCII values ? Or is there a way to get normal numbers (like 18)?

If it can only return ASCII values, than I should read values until CR and discard the LF and get the normal number ?

Thanks for reply ;)

Well, as long as your values don't exceed 255, you could use Or you could subtract the ASCII value for zero ('0' == 0x30) from every digit and multiply by the decimal postition.

Look around the forum; it seems like this problem comes up every other day.

Thank you 8-) I'll try that as soon as I have some spare time :)

Just tried it and it worked like a charm !
Thank you! [smiley=2vrolijk_08.gif]