Hello,
It works here when I connect to the correct serial port.
Try adding this to setup() to see which COM ports are available:
https://processing.org/reference/libraries/serial/Serial_list_.html
Another resource:
https://itp.nyu.edu/physcomp/lessons/serial-communication/interpreting-serial-data/

Arduino:
void setup()
{
//Int serial port for data
Serial.begin(9600);
}
void loop()
{
// capture data in arduino
int variable1 = int(random(100));
Serial.println(variable1);
delay(100);
}
Processing:
import processing.serial.*;
Serial mySerial;
String myString = null;
int ml = 10;
float myVal;
void setup()
{
size(200, 400);
// List all the available serial ports
printArray(Serial.list());
String myPort = Serial.list() [0];
mySerial = new Serial(this, myPort, 9600);
}
void draw()
{
while (mySerial.available() > 0)
{
myString = mySerial.readStringUntil(ml); //striping data
if (myString != null)
{
background(0);
myVal = float(myString);
println(myVal);
}
}
}
This needs work:
// rect(width/2, height =(myVal/2), 100, myVal);
I will leave that with you.
