This reference may or may not be helpful; it contains a Processing sketch. We can help with basic code to connect to serial but there is quite a bit of data being sent from one of these gyros: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/Graph/Graph.pde
Basic Serial Code for Processing:
import processing.serial.*;
Serial myPort; // The serial port
String inStr; // Input string from serial port
int lf = 10; // ASCII linefeed
float x, y, z;
void setup() {
surface.setVisible(false); // Output is in console at bottom of editor
// List all the available serial ports:
printArray(Serial.list());
// Enter device number for your system
myPort = new Serial(this, Serial.list()[4], 9600);
myPort.bufferUntil(lf);
}
void draw() {
}
void serialEvent( Serial myPort) {
//'\n' (line feed) is delimiter indicating end of packet
inStr = myPort.readStringUntil('\n');
//make sure our data isn't empty before continuing
if (inStr != null) {
//trim whitespace and formatting characters (like carriage return and/or line feed)
inStr = trim(inStr); //Data is sent as a string
println("inStr = ", inStr);
String[] myData = split(inStr, ','); // String is split into array at comma
//printArray(myData);
x = Float.valueOf(myData[0]); // Array elements are converted back to integers
println("x = ", x);
y = Float.valueOf(myData[1]);
println("y = ", y);
z = Float.valueOf(myData[2]);
println("z = ", z);
}
}
Arduino code for testing purposes:
int randNumber[3];
void setup() {
Serial.begin(9600);
}
void loop() {
// print a random number from 0 to 299
randNumber[0] = random(300);
Serial.print(randNumber[0]);
Serial.print(','); // Comma separated values
// print a random number from 10 to 19
randNumber[1] = random(10, 20);
Serial.print(randNumber[1]);
Serial.print(',');
// print a random number from 500 to 899
randNumber[2] = random(500,900);
Serial.println(randNumber[2]);// line feed terminated
delay(50);
}