Use the Arduino Processing Interface

please post your code ( using </> Preformatted text )
and also the console print out.


minimal arduino code

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print( analogRead(0) );          // A0
  Serial.print(",");
  Serial.print( analogRead(1) );          // A1
  Serial.println(",");
  delay(1000);                            // every second
}


/* if A0 at 5V see on arduino monitor
1023,868,
1023,867,
1023,866,
1023,865,
1023,866,
1023,866,
1023,867,

*/

minimal processing code

import processing.serial.*;

Serial myPort; 
String data;

void setup_serial() {                                 // USB arduino..
  printArray(Serial.list());
  String portName = Serial.list()[1]; 
  myPort = new Serial(this, portName, 9600);
  myPort.clear();
  myPort.bufferUntil('\n');
  println("try connect to "+portName);
}

void serialEvent(Serial p) {                          // handle serial data
  data = trim(p.readStringUntil('\n'));
  if (data != null) {
    println(data);            // print every GOOD line
  }
}

void setup() {
  size(640, 360);
  setup_serial();
}

void draw(){}

/*

[0] "COM1"
[1] "COM7"
try connect to COM7
1023,869,
1023,833,
1023,862,
1023,866,
1023,866,

*/

with a arduino leonardo on USB COM7
of a Win 10 / Processing 3.5.3 /

1 Like