Arduino problem
in
Integration and Hardware
•
3 years ago
Hello,
I am trying to pass some data from the arduino to the processing.
I am passing 3 values like xxx,yyy and zzz as one long: xxxyyyzzz
This is part of my code:
- void serialEvent (Serial myPort) {
- // get the ASCII string:
- String inString = myPort.readStringUntil('\n');
- if (inString != null) {
- grid();
- stroke(0);
- line(x,0,x,height);
- // trim off any whitespace:
- inString = trim(inString);
- // convert to an int and map to the screen height:
- inByte = int(inString);
- y1 = (inByte/1000000);
- y2 = inByte/1000-y1*1000;
- y3 = inByte-y1*1000000-y2*1000;
- y1 = round(map(y1, 0, 1023, 0, height));
- y2 = round(map(y2, 0, 1023, 0, height));
- y3 = round(map(y3, 0, 1023, 0, height));
- print("x : ");
- print(y1);
- print(" |y: ");
- print(y1);
- print(" |z: ");
- println(y3);
Whats my problem please?
Thank you.
1