View difference between Paste ID: wCmVaGrt and i4yYQixX
SHOW: | | - or go back to the newest paste.
1
import processing.serial.*;
2
float data = 0;        
3
Serial myPort;
4
5
void setup() {
6
  size(160, 128);
7
  println(Serial.list());
8
  myPort = new Serial(this, Serial.list()[3], 9600);
9
  myPort.bufferUntil('\n');
10
}
11
12
void draw() {  
13
}
14
15
void serialEvent(Serial myPort) {
16
  String inString = myPort.readStringUntil('\n');
17
  if (inString != null) {
18
    inString = trim(inString);
19
    float[] coordinates = float(split(inString, ","));
20
    if (coordinates.length >=1) {
21
      data = coordinates[0];
22
      println(data);
23
     // y = coordinates[1];
24
     // z = coordinates[2];
25
    }
26
  }
27
}