What is right method to pass led info from processing to arduino

thank you [kfrajer]; I have commented out the serial events. This way you can use the code in processing. mainly I would like to know how to clear the color bar after clear is pressed. I will work on the other.

//generate color barcode by typing input , 
//save it to computer and broadcast the colors

import processing.net.*;
import processing.serial.*;
import java.util.*;
import java.lang.reflect.*;
import java.security.*;
import java.awt.Graphics2D;
import controlP5.*;

ControlP5 cp5;
import processing.serial.*;

//Serial arduinoPort;

    //Start with an array to store the colorbars.
    int[] colorLines;
    int[] red;
    int[] green;
    int[] blue;
   int n;
   int r1;
   int g1;
   int b1;
    int time;
  
   int rate1;
   int rate2;
   int rate3;
 
   
  boolean hasBeenDrawn = false;
  boolean hasBeenInput = false;
   String inputText;
   boolean colorCodeClear = false;
   String textValue;
   
 
  
    void setup(){
      size(400,280);
    
   // Create the array for  width of lines.
       
   {n = 400;
    colorLines = new int[n];
    red = new int[n];
    green = new int[n];
     blue = new int[n];
      // Populate the array with some values.
      for( int i=0; i < colorLines.length; i++){ 
        strokeCap(SQUARE);
        int sW = int(random(20,40));
        strokeWeight(sW);       
      colorLines[i] = sW;
      }
      //noLoop();
    }
  // set arduino port 
 //arduinoPort = new Serial(this,"/dev/tty.usbmodem1411", 9600 );
  //create input field via CP5  
  cp5 = new ControlP5(this);
  cp5.addTextfield("Enter Name")
  .setPosition(0, 10)
  .setSize(200,30)
  .setAutoClear(false) 
  .setFont(createFont("times",20))
  .setColor(255);
 //cp5.getController("Enter Name").getCaptionLabel().setColor(color(148,0,211) );
 cp5.getController("Enter Name").getCaptionLabel().setSize(14);

  
  
  cp5.addBang("clear")
     .setPosition(240,10)
     .setSize(100,20)
     .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
     ;    
  
  
    }
    void draw()
    {
     background(0);
    
   inputText = cp5.get(Textfield.class,"Enter Name").getText();
   text(inputText,50,70);

    }
    
  void keyPressed() { 
    if (keyCode == ENTER)
    {
      {colorCode();
       broadcast();
       println(inputText);
     
      if (hasBeenDrawn == false)
      {
        
      {saveColorCode();
    hasBeenDrawn = true;
     cp5.getController("Enter Name").getCaptionLabel().setSize(2);
      }
    }
    }
  }
    }

    
   void colorCode()   
   {  
      //Draw each line.
      for( int i = 0; i < 400; i += 16 )
      {
    // Give each line a random color and width each time it's drawn.
     strokeWeight(colorLines[i]);

   float r = int(random(255));
    red[i]=int(r);
    float g = int(random(255));
    green[i] = int(g);
    float b = int(random(255));
    blue[i] = int(b);//blue
    
    stroke(r, g, b);
    line(i, 60 ,i, height);
      }
      }

  //ready for led turn ons using Arduino RGB control 2
  void broadcast()
  { 
    for( int i = 0; i < 400; i += 16 )
    {
     r1 = red[i];
     g1 = green[i];
    b1 = blue[i];
    time = colorLines[i];
  byte out[] = new byte[4];
  out[0] = byte(r1);
  out[1] = byte(g1);
  out[2] = byte(b1);
  //send carriage return character 
  out[3] = byte('\r');
    println(out);
  //arduinoPort.write(out);

  //println(out);
   }
 }   
   
  
  void saveColorCode() {
    g = createGraphics(400,200);
    //this.height = dim;
    //this.width = dim;
    g.beginDraw();
    for (int i = 0; i < n; i += 16 )
    {
    strokeWeight(colorLines[i]); 
    stroke(red[i],green[i],blue[i]);
    line(i, 0, i , 250); 
  //put input on top of colorcode
    }
    g.textSize(48);
    g.fill(red[0],green[0],blue[0]);
    g.text(inputText,50,50);
    g.endDraw();
  
    save(inputText);
    println("screenshot saved");
}

public void clear() {
  cp5.get(Textfield.class,"Enter Name").clear();
  cp5.getController("Enter Name").getCaptionLabel().setSize(14);
  colorCodeClear = true;
}
 
 

  

/*void mousePressed(){
  g.beginDraw();
  g.clear();
  g.endDraw();
  //rect(0,20,400,200);
}*/ 

void controlEvent(ControlEvent theEvent) {
  if(theEvent.isAssignableFrom(Textfield.class)) {
    println("controlEvent: accessing a string from controller '"
            +theEvent.getName()+"': "
            +theEvent.getStringValue()
            );
  }
}


public void input(String theText) {
  // automatically receives results from controller input
  println("a textfield event for controller 'input' : "+theText);
}```

I have written this little code;```import processing.serial.*;

Serial serialPort;
  String[] portNames = Serial.list();
  int len = portNames.length ;
  println("portNames has "+len+" elements");
 
  for (int i=0 ; i<len ; i++ )
  {
  println(portNames[i]);
  }
 String portName4 = new String( portNames[3]);   // usual needs to be portNames[1] for arduino
 
serialPort = new Serial(this,portName4, 9600);
serialPort.write(65);```     console shows portNames has 8 elements
/dev/cu.AngelmansiPhone-Wireles-1
/dev/cu.Bluetooth-Incoming-Port
/dev/cu.RadhasMacBookPro-Blueto
/dev/cu.usbmodem1411
/dev/tty.AngelmansiPhone-Wireles-1
/dev/tty.Bluetooth-Incoming-Port
/dev/tty.RadhasMacBookPro-Blueto
/dev/tty.usbmodem1411

but where does the letter A (65) meant to appear in the Arduino ?