Serial communication with Processing

I need that my Arduino communicates with Processing, but without Firmata.

However I have a little problem. If I write this code on arduino:

void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println(analogRead(0));
}

and this on Processing

import processing.serial.*;
Serial myPort;  


void setup() 
{
  myPort = new Serial(this, "COM3", 9600);
}

void draw()
{
  if ( myPort.available() > 0) {  
     println (myPort.read());    
  }

}

...processing reads only these wrong values (Arduino serial monitor reads the right ones):

13 10 54 49 48 13 10 54 49 48

Why?

...processing reads only these wrong values (Arduino serial monitor reads the right ones):

No, it doesn't. 10 is a line feed. 13 is a carriage return. 54 is a '6'. You can look at an ASCII table to figure out the rest.

You need to collect the data in a character array, and use atoi() to convert the character array to an int. Or use Processing's string handling functions that do the same thing.

Could you please give me an example of how should I use the function atoi()?

hi there,

i got the exact same problem

if i use readString instead, i get the correct data. but if i use readString, i cant display the text with my gui, i only can read with println in processing monitor.

i only can read with println

Really? Would you care to explain how you can read (input) anything using an output function?