Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Serial communication

$
0
0
Hi,
I am a beginner of Processing.


I use both Arduino and Processing.
I try to send the data collecting by Arduino to Processing with the serial communication.

However, when I use the serial communication, the data of Arduino and Processing are different.
If someone have any idea, please tell me.

I give my program bellow.

And this is the first time to ask on the web community, so please tell me the information which I forget to give.

Thank you.

-----
import processing.serial.*;
Serial myPort;
String datastr;
PrintWriter output;
int count = 1;
int[] x;

void setup()
{
  println(Serial.list());  //show all usable ports
  myPort = new Serial(this, Serial.list()[0], 9600);
  // the first serial port is 9600bps
  myPort.clear();
  output = createWriter("log1.txt");  //open the file as "log.txt"
}

void draw() {
  if ( count > 100) {  //finish if the counter overs 100
    x = new int[6];
    for(int i = 0; i < 6; i++) {
    x[i] = myPort.read();
    print(x[i]);
    output.print(x[i]);
    output.print(",");
    //output.flush();  // write all data
    }
    output.close();  // close the file
    exit();
    println("count ni hairimashita");
  }
  count++;  // count up
}
-----

Viewing all articles
Browse latest Browse all 1768

Trending Articles