Processing sending ASCII - need int over serial?

Hi,

I am trying to send some integer values over serial to an Ardunio from processing.

text(“X:” + xrot_val, 0, 50);
text(“Z:” + zrot_val, 100, 50);
serialPort.write(xrot_val);
serialPort.write(zrot_val);

I know the xrot_val etc are integers as I get them as numbers on screen.

The serial output is in ascii, and I can’t find a way in processing to convert to an integer.

Even tried serialPort.write(int(xrot_val)); with no luck.

Any ideas?

Cheers!

itoa()

Or int to ascii. Eg

char istr[10]; // Need enough storage for the number as a string

itoa(15, istr, 10);

the result will be 15 (decimal) as a string contained in istr. The 10 as the last param is the base to conver to. Eg itoa(15, str, 2) will give 15 in binary (1111) within istr

Thanks,

I get the function atoi(int) does not exist in processing.

?

Fixed.

Ta.