We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all, Im trying to run a code on my computer (win8.1, x64) using Processing 3.0b6 I downloaded today. It doesnt work, but this the same code works on my old computer (win7 SP1, x86) using Processing 2.2.1. When I try to execute the code, nothing happens neither the presentation windows, console or erros tab appears.
Could someone say how to fix it? Thanks in a advanced!
The code is below:
import processing.serial.*;
Serial myPort; // The serial port
float acc_roll=0, acc_pitch=0, acc_yaw=0, gyr_roll=0, gyr_pitch=0, gyr_yaw=0, roll=0, pitch=0, yaw=0;
PFont f;
void setup() {
size(800, 800, P3D);
try {
myPort = null;
myPort = new Serial(this, "COM3", 9600);
myPort.bufferUntil('\n');
}
catch(Exception e) {
e.printStackTrace();
}
f = createFont("Arial", 16, true);
}
void draw() {
background(255);
stroke(175);
// line(0,height/2,width,height/2);
// line(width/2,0,width/2,height);
textFont(f);
fill(0);
//TEXTS
textAlign(CENTER);
//ACCELEROMETER
text("ACCELEROMETER",width/4,height/32);
text("Roll",width/8,height/16);
text(acc_roll,width/8,height/16+15);
text("Pitch",width/4,height/16);
text(acc_pitch,width/4,height/16+15);
text("Yaw",3*width/8,height/16);
text(acc_yaw,3*width/8,height/16+15);
//GYROSCOPE
text("GYROSCOPE",3*width/4,height/32);
text("Roll",5*width/8,height/16);
text(gyr_roll,5*width/8,height/16+15);
text("Pitch",3*width/4,height/16);
text(gyr_pitch,3*width/4,height/16+15);
text("Yaw",7*width/8,height/16);
text(gyr_yaw,7*width/8,height/16+15);
//FILTRATED (Fusion)
text("FILTRATED (Fusion)",width/2,15*height/32);
text("Roll",3*width/8,height/2);
text(roll,3*width/8,height/2+15);
text("Pitch",width/2,height/2);
text(pitch,width/2,height/2+15);
text("Yaw",5*width/8,height/2);
text(yaw,5*width/8,height/2+15);
//DRAWING
fill(0,0,139);
//ACCELEROMETER
pushMatrix();
translate(width/4, height/4);
rotateX(acc_roll/55);
rotateY(acc_pitch/55);
rotateZ(acc_yaw/55);
box(100,200,10); // box(64,98,1);
popMatrix();
//GYROSCOPE
pushMatrix();
translate(3*width/4, height/4);
rotateX(gyr_roll/55);
rotateY(gyr_pitch/55);
rotateZ(gyr_yaw/55);
box(100,200,10);
popMatrix();
//FILTRATED (Fusion)
pushMatrix();
translate(width/2, 22*height/32);
rotateX(roll/55);
rotateY(pitch/55);
rotateZ(yaw/55);
box(100,200,10);
popMatrix();
}
void serialEvent(Serial myPort)
{
String inString = myPort.readString();
float[] vals = float(split(inString,";"));
acc_roll=vals[0];
acc_pitch=vals[1];
acc_yaw=vals[2];
gyr_roll=vals[3];
gyr_pitch=vals[4];
gyr_yaw=vals[5];
// roll=vals[6];
// pitch=vals[7];
// yaw=vals[8];
}
Answers
P.S.: The way your code is, it can even work under the old Processing 1.5.1! ;))