Please help me on getting the solution about this.The processing has an output but it is not copied on the text file.All i want is to copy the output of the preccing which is from the arduino program.The output is for example (1 2 3)...........(2 3 4).....This values is for acceleration on X Y Z axis which is program ont he arduino. Pls help me...
Thanks for the answer.
///import processing.opengl.*;
import processing.serial.*;
Serial sp;
byte[] buff; //buff input String read from serial com port
float[] r;
PrintWriter output; //to output to text file
int OFFSET_X = 0, OFFSET_Y = 0, OFFSET_Z=0;
//These offsets are chip specific, and vary.
void setup()
{
sp = new Serial(this, "COM6", 9600); //creating new serial communication port
buff = new byte[128];
r = new float[5];
// Create a new file in the sketch directory
output = createWriter("wew54.txt");
}
void draw()
{
int bytes = sp.readBytesUntil((byte)10, buff); //receiving the input String from the serial port
String mystr = (new String(buff, 0, bytes)).trim();
if(mystr.split(" ").length != 5)
{
println(mystr);
return;
}
setVals(r, mystr);
float x = r[0], y = r[1], z = r[2];
println(x+ "\t" + y + "\t" + z+"\t"); //printing to screen
output.println(x+ "\t" + y + "\t" + z+"\t");
//printing to text file
}
void setVals(float[] r, String s)
{
int i = 0;
r[0] = (float)(Integer.parseInt(s.substring(0, i = s.indexOf(" ")))+OFFSET_X);
r[1] = (float)(Integer.parseInt(s.substring(i+1, i = s.indexOf(" ",i+1))) + OFFSET_Y);