import processing.serial.*;

Serial myPort;
String inputString = "";
boolean showCircle = false;

void setup(){
  
 size(400,400);
 printArray(Serial.list());
 myPort = new Serial(this,Serial.list()[4],9600);
 myPort.bufferUntil('\n'); // 改行まで受信したらserialEventへ
 
}

void draw(){
   background(0,0,0);
   
   if(showCircle){
      fill(0,255,0);
      ellipse(width/2,height/2,100,100);
   }
}

void serialEvent(Serial p){
    inputString = trim(p.readStringUntil('\n'));
    if(inputString.equals("down")){
       showCircle = true; 
    }else if (inputString.equals("up")){
       showCircle = false; 
    }
}
