/* right the port */void mousePressed(){ if(!serialPortFound){/* right the port */void mousePressed(){ if(!serialPortFound){

/* serial library allows us to communicate with arduino */import processing.serial.*; Serial port;/* finds the correct serial port */String serialPort;String serialPorts = new StringSerial.list().length;boolean serialPortFound = false;Radio button = new RadioSerial.list().length*2;int numPorts = serialPorts.length;boolean refreshPorts = false;/* lists all ports available */void listAvailablePorts(){  println(Serial.list());  // prints list of avaiable serial ports to computer  serialPorts = Serial.list();  fill(0);  textAlign(LEFT);  /* lists them backwards */  int yPos = 0;   int xPos = 35;  for(int i=serialPorts.length-1; i>=0; i–){    buttoni = new Radio(xPos, 95+(yPos*20),12,color(180),color(80),color(255),i,button);    text(serialPortsi,xPos+15, 100+(yPos*20));    yPos++;    if(yPos > height-30){      yPos = 0; xPos+=200;    }  }  int p = numPorts;  fill(233,0,0);  buttonp = new Radio(35, 95+(yPos*20),12,color(180),color(80),color(255),p,button);  text(“Print the ports list again “,50, 100+(yPos*20)); // option to refresh ports page again  textAlign(CENTER);}/* deals with user selecting right the port */void mousePressed(){  if(!serialPortFound){    for(int i=0; i<=numPorts; i++){      if(buttoni.pressRadio(mouseX,mouseY)){        if(i == numPorts){          if(Serial.list().length > numPorts){            println(“New Ports Opened!”);            int diff = Serial.list().length – numPorts;             serialPorts = expand(serialPorts,diff);            numPorts = Serial.list().length;          }else if(Serial.list().length < numPorts){            println("Some Ports Closed!");            numPorts = Serial.list().length;          }else if(Serial.list().length == numPorts){            return;          }          refreshPorts = true;          return;        }else         try{          port = new Serial(this, Serial.list()i, 115200);  // make sure arduino is talking serial at this baud rate          delay(1000);          println(port.read());          port.clear(); // flush buffer          port.bufferUntil(' ');  // set buffer full flag on receipt of carriage return          serialPortFound = true;        }        catch(Exception e){          println("Couldn't open port " + Serial.list()i);          fill(255,0,0);                    textAlign(LEFT);          text("Couldn't open port " + Serial.list()i,60,70);                    textAlign(CENTER);        }      }    }  }}class Radio {  int _x,_y;  int size, dotSize;  color baseColor, overColor, pressedColor;  boolean over, pressed;  int me;  Radio radios;  Radio(int xp, int yp, int s, color b, color o, color p, int m, Radio r) {    _x = xp;    _y = yp;    size = s;    dotSize = size - size/3;    baseColor = b;    overColor = o;    pressedColor = p;    radios = r;    me = m;  }  boolean pressRadio(float mx, float my){    if (dist(_x, _y, mx, my) < size/2){      pressed = true;      for(int i=0; i