Interpreting Serial Port Data in Java -- A beginners question

Hello all,

I am brand new to the arduino, and electronics in general. I'm decent with programming and OK with Java, but I'm running into a simple problem. When I run my arduino code I am sending integer values to the serial port, and my serial monitor displays them appropriately (they should be rising from 0 to 255 and then falling back down to 0). However when I get RXTX going in Java, and I read the data in from the serial port, I am getting values in the range of 40 - 60.

So my question is, can anybody tell me the simplest way to send values out from the arduino as integers and have Java + rxtx receive the values as those same integers?

Any advice would be greatly appreciated! Thanks!

When I run my arduino code I am sending integer values to the serial port, and my serial monitor displays them appropriately (they should be rising from 0 to 255 and then falling back down to 0).

And that code looks like?

However when I get RXTX going in Java, and I read the data in from the serial port, I am getting values in the range of 40 - 60.

Perhaps a quick peak at an ASCII table would prove enlightening.

http://www.asciitable.com/

Pay particular attention to the values for '0', '1', '2', ..., '9'.

I hope this tutorial helps you:

http://www.whatisarduino.org/bin/Tutorials/Java+Serial+API+and+Arduino

Have a nice day.