Looking for some help with the processing Serial
in
Contributed Library Questions
•
11 months ago
Hey everyone, hope I'm not in the wrong place, but anyway.
I'm having a few issues with sending information down the serial.
What I'm doing is taking some accelerometer and touch data from a phone, bundling it up so that it looks something like this: <0060,0050,00> and then sending it away to Arduino for playing with servos.
But that's not really important.
What I'm finding is that for a while Processing is happily getting and sending away these packets of data down the serial port before just stopping. No error messages, no indication that something's wrong, it just stops everything. This is not what I'm after (as you can safely assume), I just want it to keep receiving and sending this data forever without issue. I don't know if this is because the buffer is full or how I would fix it, but any assistance would be greatly appreciated.
Here's my code, hopefully it shall help out.
I'm having a few issues with sending information down the serial.
What I'm doing is taking some accelerometer and touch data from a phone, bundling it up so that it looks something like this: <0060,0050,00> and then sending it away to Arduino for playing with servos.
But that's not really important.
What I'm finding is that for a while Processing is happily getting and sending away these packets of data down the serial port before just stopping. No error messages, no indication that something's wrong, it just stops everything. This is not what I'm after (as you can safely assume), I just want it to keep receiving and sending this data forever without issue. I don't know if this is because the buffer is full or how I would fix it, but any assistance would be greatly appreciated.
Here's my code, hopefully it shall help out.
import processing.serial.*;
Serial myPort;
import oscP5.*;
import netP5.*;
String yy;
String zz;
String ii = "00";
String sending;
OscP5 osc;
void setup() {
osc = new OscP5(this, 10000);
osc.plug(this, "tilting", "/tilt");
osc.plug(this, "touching", "/touch");
println(Serial.list());
myPort = new Serial (this, Serial.list()[0], 9600, 'N', 8, 1.0);
}
void draw () {
sending = "<"+yy+","+zz+","+ ii+">";
myPort.write(sending);
println (sending);
}
void touching(int i) {
ii = nf(i, 2);
}
void tilting(float x, float y, float z) {
yy = nf(round(map (y, 0, 127, 0, 180)), 3);
zz = nf(round(map (z, 0, 127, 0, 180)), 3);
yy = '0' + yy;
zz = '0' + zz;
delay(10);
}
1