Interfacing w/ Software on the Computer
Interactive Helmet + Glove project. Arduino/Processing interfacing
Topic: Interactive Helmet + Glove project. Arduino/Processing interfacing
(Read 1 time)
Location: Seattle, WA USA
Seattle, WA USA
Re: Interactive Helmet + Glove project. Arduino/Processing interfacing
May 28, 2011, 03:40 pm
val = port.read();
reads one byte from the serial port.
int val = 0; // To store data from serial port, used to color background
What color is the string "Analog reading2 = 600 - Medium squeeze", when read one byte at a time, supposed to correspond to?
I think that you need to break the Processing project up into steps. First, get Processing to echo the data send to the serial port, by the Arduino, one character at a time.
Then, change the Processing application so it reads an entire buffer of data. That requires the use of the bufferUntil() function in setup(), and requires that the Arduino send the specific buffer until character (typically a carriage return). Again, just echo the input.
Then, change the Arduino code to get rid of the extra crap it is sending. Just send the analog values as strings.
Then, the Processing application can be revised to convert the received string to whatever data type is appropriate, int in this case, and store it in the appropriate variable that draw() uses to do something.