Go Down

Topic: Interactive Helmet + Glove project. Arduino/Processing interfacing (Read 1 time) previous topic - next topic


Code: [Select]
val = port.read();
reads one byte from the serial port.

Code: [Select]
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.

Go Up