// longeur/largeur du tableau. changer a votre convenance ;) int Lx=900; //default: 900 int Ly=600; //default: 600 import processing.serial.*; Serial monPortamoi; Serial monPortamoi2; Serial monPortamoi3; Serial monPortamoi4; int x; int y; int clicX; int clicY; int coeff=10; // <1 multiplie, >1 divise, 1 inchangé. float l1=0; float l2; float l3; float l4; float savel1=540; float savel2=540; float savel3=540; float savel4=540; float calcull1; float calcull3; void setup() { size(Lx+500,Ly); //taille du tableau. a definir plus haut println(Serial.list()); String arduinoPort = Serial.list()[1]; //String arduinoPort2 = Serial.list()[0]; String arduinoPort3 = Serial.list()[0]; //String arduinoPort4 = Serial.list()[1]; monPortamoi = new Serial(this, arduinoPort, 9600); //monPortamoi2 = new Serial(this, arduinoPort2, 9600); monPortamoi3 = new Serial(this, arduinoPort3, 9600); //monPortamoi4 = new Serial(this, arduinoPort4, 9600); } void draw() { background(0); //fond noir fill(0,0,0); //remplir en noir stroke(0,200,200); //contour bleu rect(Lx,0,200,Ly); //boite rect(Lx,0,200,180); //boite //ellipse(x, height-y, 10,10); ellipse(x, mouseY, 10,10); x=mouseX; //x=position x de la souris y=height-mouseY; // y=hauteur-position y de la souris x=constrain(x,0,Lx); //contrainte de la souris. pour pas qu'elle ne se ballade dans les stats //traçage des lignes l1 l2 l3 l4 line(0,0,x,height-y); line(Lx,Ly,x,height-y); line(Lx,0,x,height-y); line(0,Ly,x,height-y); texte(); } void mouseClicked () { if( mouseX0) { monPortamoi2.write("cmdH"+int(calcull2)+"\r"); print("envoi message : "); println("cmdH"+int(calcull2)); } if (calcull2<0) { monPortamoi2.write("cmdT"+int(abs(calcull2))+"\r"); print("envoi message : "); println("cmdT"+int(abs(calcull2))); } /*******************MESSAGE TREUIL3*******************************/ if (calcull3>0) { monPortamoi3.write("cmdH"+int(calcull3)+"\r"); print("envoi message : "); println("cmdH"+int(calcull3)); } if (calcull3<0) { monPortamoi3.write("cmdT"+int(abs(calcull3))+"\r"); print("envoi message : "); println("cmdT"+int(abs(calcull3))); } /*******************MESSAGE TREUIL4******************************* / if (calcull4>0) { monPortamoi4.write("cmdH"+int(calcull4)+"\r"); print("envoi message : "); println("cmdH"+int(calcull4)); } if (calcull4<0) { monPortamoi4.write("cmdT"+int(abs(calcull4))+"\r"); print("envoi message : "); println("cmdT"+int(abs(calcull4))); }*/ }