import processing.serial.*; int dg; int angle; Serial port; float mx =0.0; void setup(){ size(640,480); noStroke(); frameRate(50); port = new Serial(this,"/dev/cu.usbserial-A700eEjj",9600); } void draw(){ background(0); //background is black fill(204); //set Panel's fill color to 204 rect(40,height/2+135,560,50); // panel rect(x,y,width,height) float dif = mouseX -mx; if (abs(dif) > 1.0){ mx +=dif/4.0; } mx = constrain(mx,0,540); noStroke(); fill(255); // white bar 255 rect (50,(height/2)+145, 540,30); fill(204,102,0); //fill(R,G,B) Red cursor rect(50, height/2+145,4+mx,30); //int angle = int(map(mx,0,540,0,255)); angle = int(map(mx,0,540,0,255)); int vol = int(map(mx,0,540,0,100)); textSize(32); text(vol,290,350); text("%",355,350); fill(225); ellipse(320,200,180,180); fill(50); for (int d = 0; d <=4; d++){ arc(320, 200, 150,150,0-PI/2*d+PI/900*dg*angle,PI/4-PI/2*d+PI/900*dg*angle); } fill(225); ellipse(320,200,30,30); if (angle > 0){ dg++; } if (dg == 900) dg =0; port.write(angle); }