Tweak the Arduino Logo ISSUE

Hey guys, sorry for asking such a stupid question but I'm having some issues with project 14 on the Arduino Starter Kit. I already searched amongst the other previous topics but didn't find the answer.

The code is simple, and it should work fine, but the bg color on the processing sketch flickers and doesn't respond to the movement of my potentiometer.

The serial monitor on the Arduino sketch seems to work just fine, ASCII text is flowing, but when I launch the Processing sketch it seems to have it's own life.

void setup() {
  // initialize the serial communication:
  Serial.begin(9600);
}

void loop() {
  // send the value of analog input 0:
  Serial.write(analogRead(A0)/4);
  // wait a bit for the analog-to-digital converter
  // to stabilize after the last reading and to give Processing
  // time to draw the next frame on screen
  delay(1);
}
import processing.serial.*;

Serial myPort;

PImage logo;

int bgcolor = 0;

void setup() {
  
  colorMode(HSB, 255);
  
  logo = loadImage("logo.png");
  
  size(logo.width, logo.height);
  
  println("Available serial ports:");
  println(Serial.list());
  
  myPort = new Serial(this, Serial.list()[7], 9600);
  
}

void draw() {
  
  if (myPort.available() >= 0) {
    
    bgcolor = myPort.read();
    
    println(bgcolor);
    
  }
  
  background(bgcolor, 255, 255);
  
  image (logo, 0, 0);
}

OSC_A.ino (343 Bytes)

OSC_P.pde (510 Bytes)

void draw() {

if (myPort.available() >= 0) {

bgcolor = myPort.read();

Do NOT read serial data in draw(). There is a serialEvent() method that you should implement, instead.

Are there REALLY 8 or more ports listed? If so, you need to unplug some crap.

PaulS, could you go into more detail on how to implement the serialEvent() method please?

mikeyh30:
PaulS, could you go into more detail on how to implement the serialEvent() method please?

No, but the Processing people can:
https://processing.org/reference/libraries/serial/serialEvent_.html