Pages: [1]   Go Down
Author Topic: send two values to processing via serial port  (Read 518 times)
0 Members and 1 Guest are viewing this topic.
Recanati (MC)
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi! i'd like to know if someone has ever tried to send two different values from a single serial port.. i wonder how it could be possible to parse the information in processing in order to put those values into different variables.. any suggestions?

thanks in advance!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50304
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i'd like to know if someone has ever tried to send two different values from a single serial port.
Yes, of course.

Code:
Serial.print(47);
Serial.print(",");
Serial.println(99);

Quote
i wonder how it could be possible to parse the information in processing in order to put those values into different variables.
Open the serial port. Use the bufferUntil() method to define when to call the serialEvent() callback.

Define the serialEvent() callback. In that function, the String returned by Serial.read() will contain the whole string read. That string can be split into an array of integers, in one step.
Logged

Recanati (MC)
Offline Offline
Jr. Member
**
Karma: 0
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i've come to realize i don't have any ideas of how to even read a single value. would you mind pointing me to any tutorial or stuff? all the examples in processing work in different ways, making it hard to understand the whole reading process
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are examples supplied with Processing that show serial communication to/from an Arduino, in Examples->Serial I/O.
Logged

Pages: [1]   Go Up
Jump to: