Serial connection between Processing and Arduino doesn’t work

This version of your sketch works. Note the four //!

import processing.serial.*;

Serial myPort;
String val;

void setup()
{
  frameRate(40);              //!
  String arduinoPort = "COM4";
  myPort = new Serial(this, arduinoPort, 9600);
  myPort.bufferUntil('\n');   //!
}
void serialEvent(Serial myPort) {
  val = myPort.readString();  //!
  print(val);
}
void draw(){}                 //!
1 Like