We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › q regarding strings
Page Index Toggle Pages: 1
q regarding strings (Read 496 times)
q regarding strings
Aug 21st, 2009, 10:58pm
 
hey guys\girls,

I have a very simple question regarding  strings.

I have a arduino passing a series of sensor values trough the serial interface.

this is what the string looks like...

eg: 510,150,150,150,150,450,450,890

I have written the basic code in Processing to show these values in a window.
I can't figure out how to split the string up and display the values in the window.

I have had a look at one page in "Physical Computing at ITP" and I can split the string and get the values to show in the the applet.

I've tried using the method described in link in article named "Visualizing Sensor data with Arduino"

could someone please she some light on this... I'm pretty new to the serial communication programming.


edit: I forgot to add I can work out how to split the string into a array to display in the applet. I would prefer to split it onto strings to show them in the window. These readings get updates every second.

Thanks heaps...



Re: q regarding strings
Reply #1 - Aug 22nd, 2009, 1:25am
 
did you check out http://processing.org/reference/split_.html ?
just split your string into an array of strnigs. use a for loop to display them all. And as your string gets updated your arrays gets updated too and should display the new values...

Re: q regarding strings
Reply #2 - Aug 22nd, 2009, 3:01am
 
Yeah, just had a look at that. Got it working using that method.

I was looking at that exact code and completely over looked that... Embarrassed
Re: q regarding strings
Reply #3 - Aug 22nd, 2009, 6:41am
 
Take a look at the Java documentation when you need to do fancy stuff with strings. There are a ton of great methods that do all sorts of cool stuff!

Here's the link: Java String Documentation
Page Index Toggle Pages: 1