
Base roulante avec bras
#342
Posté 08 septembre 2012 - 08:59
je te conseil d'attendre une autre confirmation car je peut me tromper.
personnellement j'utilise un bleusmirf gold et je n'ai aucun problème avec

#343
Posté 09 septembre 2012 - 04:55

Sinon je voulais vous annoncer que j'avance dans mon Projet. J'ai mes L293D ils sont connecter et tout , j'ai mis mon code et je le fais fonctionner sous Processing. Voila les codes :
Arduino
int baseMotorEnablePin = 2; int baseMotorPin1 = 3; int baseMotorPin2 = 4; int shoulderMotorEnablePin = 14; int shoulderMotorPin1 = 15; int shoulderMotorPin2 = 16; int elbowMotorEnablePin = 8; int elbowMotorPin1 = 9; int elbowMotorPin2 = 10; int wristMotorEnablePin = 5; int wristMotorPin1 = 6; int wristMotorPin2 = 7; int handMotorEnablePin = 11; int handMotorPin1 = 17; int handMotorPin2 = 18; void setup() { pinMode(baseMotorPin1, OUTPUT); pinMode(baseMotorPin2, OUTPUT); pinMode(baseMotorEnablePin, OUTPUT); digitalWrite(baseMotorEnablePin, HIGH); pinMode(shoulderMotorPin1, OUTPUT); pinMode(shoulderMotorPin2, OUTPUT); pinMode(shoulderMotorEnablePin, OUTPUT); digitalWrite(shoulderMotorEnablePin, HIGH); pinMode(elbowMotorPin1, OUTPUT); pinMode(elbowMotorPin2, OUTPUT); pinMode(elbowMotorEnablePin, OUTPUT); digitalWrite(elbowMotorEnablePin, HIGH); pinMode(wristMotorPin1, OUTPUT); pinMode(wristMotorPin2, OUTPUT); pinMode(wristMotorEnablePin, OUTPUT); digitalWrite(wristMotorEnablePin, HIGH); pinMode(handMotorPin1, OUTPUT); pinMode(handMotorPin2, OUTPUT); pinMode(handMotorEnablePin, OUTPUT); digitalWrite(handMotorEnablePin, HIGH); Serial.begin(9600); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if (incomingByte == 'Q') { digitalWrite(baseMotorPin1, LOW); digitalWrite(baseMotorPin2, HIGH); } if (incomingByte == 'W') { digitalWrite(baseMotorPin1, HIGH); digitalWrite(baseMotorPin2, LOW); } if (incomingByte == 'E') { digitalWrite(shoulderMotorPin1, LOW); digitalWrite(shoulderMotorPin2, HIGH); } if (incomingByte == 'R') { digitalWrite(shoulderMotorPin1, HIGH); digitalWrite(shoulderMotorPin2, LOW); } if (incomingByte == 'A') { digitalWrite(elbowMotorPin1, LOW); digitalWrite(elbowMotorPin2, HIGH); } if (incomingByte == 'S') { digitalWrite(elbowMotorPin1, HIGH); digitalWrite(elbowMotorPin2, LOW); } if (incomingByte == 'D') { digitalWrite(wristMotorPin1, LOW); digitalWrite(wristMotorPin2, HIGH); } if (incomingByte == 'F') { digitalWrite(wristMotorPin1, HIGH); digitalWrite(wristMotorPin2, LOW); } if (incomingByte == 'Z') { digitalWrite(handMotorPin1, LOW); digitalWrite(handMotorPin2, HIGH); } if (incomingByte == 'X') { digitalWrite(handMotorPin1, HIGH); digitalWrite(handMotorPin2, LOW); } if (incomingByte == 'O') { digitalWrite(baseMotorPin1, LOW); digitalWrite(baseMotorPin2, LOW); digitalWrite(shoulderMotorPin1, LOW); digitalWrite(shoulderMotorPin2, LOW); digitalWrite(elbowMotorPin1, LOW); digitalWrite(elbowMotorPin2, LOW); digitalWrite(wristMotorPin1, LOW); digitalWrite(wristMotorPin2, LOW); digitalWrite(handMotorPin1, LOW); digitalWrite(handMotorPin2, LOW); } } }
et Processing
import processing.serial.*; Serial port; int M1LX, M1RX, M2LX, M2RX, M3LX, M3RX, M4LX, M4RX, M5LX, M5RX; int M1LY, M1RY, M2LY, M2RY, M3LY, M3RY, M4LY, M4RY, M5LY, M5RY; int boxSize = 64; arrow myRightArrow; int[]rightArrowxpoints={30,54,30,30,0,0,30}; int[]rightArrowypoints={0,27,54,40,40,15,15}; arrow myLeftArrow; int[]leftArrowxpoints={0,24,24,54,54,24,24}; int[]leftArrowypoints={27,0,15,15,40,40,54}; PFont myFont; void setup() { size(145, 455); // base motor M1LX = 5; M1LY = 25; M1RX = 75; M1RY = 25; // epaule motor M2LX = 5; M2LY = 115; M2RX = 75; M2RY = 115; // coude motor M3LX = 5; M3LY = 205; M3RX = 75; M3RY = 205; // poignee motor M4LX = 5; M4LY = 295; M4RX = 75; M4RY = 295; // pince motor M5LX = 5; M5LY = 385; M5RX = 75; M5RY = 385; println(Serial.list()); myFont = createFont("verdana", 12); textFont(myFont); port = new Serial(this, Serial.list()[1], 9600); myRightArrow = new arrow(rightArrowxpoints,rightArrowypoints,7); myLeftArrow = new arrow(leftArrowxpoints,leftArrowypoints,7); } void draw() { background(0); noStroke(); fill(150); text("Base Motor (Q/W)", 5, 5, 200, 75); text("Shoulder Motor (E/R)", 5, 95, 200, 75); text("Elbow Motor (A/S)", 5, 185, 200, 75); text("Wrist Motor (D/F)", 5, 275, 200, 75); text("Hand Motor (Z/X)", 5, 365, 200, 75); if(keyPressed) { if (key == 'q' || key == 'Q') { port.write('Q'); } if (key == 'w' || key == 'W') { port.write('W'); } if (key == 'e' || key == 'E') { port.write('E'); } if (key == 'r' || key == 'R') { port.write('R'); } if (key == 'a' || key == 'A') { port.write('A'); } if (key == 's' || key == 'S') { port.write('S'); } if (key == 'd' || key == 'D') { port.write('D'); } if (key == 'f' || key == 'F') { port.write('F'); } if (key == 'z' || key == 'Z') { port.write('Z'); } if (key == 'x' || key == 'X') { port.write('X'); } } else if (mousePressed == true) { if (mouseX > M1LX-boxSize && mouseX < M1LX+boxSize && mouseY > M1LY-boxSize && mouseY < M1LY+boxSize) { port.write('Q'); } else if(mouseX > M1RX-boxSize && mouseX < M1RX+boxSize && mouseY > M1RY-boxSize && mouseY < M1RY+boxSize) { port.write('W'); } else if(mouseX > M2LX-boxSize && mouseX < M2LX+boxSize && mouseY > M2LY-boxSize && mouseY < M2LY+boxSize) { port.write('E'); } else if(mouseX > M2RX-boxSize && mouseX < M2RX+boxSize && mouseY > M2RY-boxSize && mouseY < M2RY+boxSize) { port.write('R'); } else if(mouseX > M3LX-boxSize && mouseX < M3LX+boxSize && mouseY > M3LY-boxSize && mouseY < M3LY+boxSize) { port.write('A'); } else if(mouseX > M3RX-boxSize && mouseX < M3RX+boxSize && mouseY > M3RY-boxSize && mouseY < M3RY+boxSize) { fill(200); port.write('S'); } else if (mouseX > M4LX-boxSize && mouseX < M4LX+boxSize && mouseY > M4LY-boxSize && mouseY < M4LY+boxSize) { port.write('D'); } else if(mouseX > M4RX-boxSize && mouseX < M4RX+boxSize && mouseY > M4RY-boxSize && mouseY < M4RY+boxSize) { port.write('F'); } else if (mouseX > M5LX-boxSize && mouseX < M5LX+boxSize && mouseY > M5LY-boxSize && mouseY < M5LY+boxSize) { port.write('Z'); } else if(mouseX > M5RX-boxSize && mouseX < M5RX+boxSize && mouseY > M5RY-boxSize && mouseY < M5RY+boxSize) { port.write('X'); } else { port.write('O'); } } else { port.write('O'); } myRightArrow.drawArrow(80,30); myRightArrow.drawArrow(80,120); myRightArrow.drawArrow(80,210); myRightArrow.drawArrow(80,300); myRightArrow.drawArrow(80,390); myLeftArrow.drawArrow(10,30); myLeftArrow.drawArrow(10,120); myLeftArrow.drawArrow(10,210); myLeftArrow.drawArrow(10,300); myLeftArrow.drawArrow(10,390); } class arrow extends java.awt.Polygon { public arrow(int[] xpoints,int[] ypoints, int npoints) { // super invokes the java.awt.Polygon class super(xpoints,ypoints,npoints); } void drawArrow(int xOffset, int yOffset){ fill(150); rect(xOffset-5, yOffset-5, boxSize, boxSize); fill(255); beginShape(); for(int i=0;i<npoints;i++){ vertex(xpoints[i]+xOffset,ypoints[i]+yOffset); } endShape(); } }
je vous posterais la video plus tard dans la journee.
A+
Cordialement Dylan.
#344
Posté 09 septembre 2012 - 09:28
Page Facebook : https://www.facebook...appartelier2.0/
Page Twitter : https://twitter.com/2Appartelier (bateau seulement)
Boutique Robot-Maker : https://www.robot-ma...er-20/produits/
Besoin d'une impression 3D grand format ? Contactez moi !
#346
Posté 28 novembre 2012 - 08:17
Woaw cela fait longtemps que j'avais plus ecris sur mon sujet. Ce soir je vous ecris , car je vais terminer ce que j'ai commencer. Apres avoir eu des mois difficiles avec des examens et pleins de cours a apprendre , je vais me consacrer un peu plus a mon projet que j'avais commencer. J'avais finis la partie electronique / Programmation de ma pince et il ne me rester plus que la partie servomoteurs et la partie Bluetooth. Je dois acheter donc mon module et mes servos.
Par contre un petit probleme est survenu aujourd'hui quand je voulais tester ma pince , avec le code arduino qui a trouver une erreur que voici :
Donc le code :
[code] int baseMotorEnablePin = 2; int baseMotorPin1 = 3; int baseMotorPin2 = 4; int shoulderMotorEnablePin = 14; int shoulderMotorPin1 = 15; int shoulderMotorPin2 = 16; int elbowMotorEnablePin = 8; int elbowMotorPin1 = 9; int elbowMotorPin2 = 10; int wristMotorEnablePin = 5; int wristMotorPin1 = 6; int wristMotorPin2 = 7; int handMotorEnablePin = 11; int handMotorPin1 = 17; int handMotorPin2 = 18; void setup() { pinMode(baseMotorPin1, OUTPUT); pinMode(baseMotorPin2, OUTPUT); pinMode(baseMotorEnablePin, OUTPUT); digitalWrite(baseMotorEnablePin, HIGH); pinMode(shoulderMotorPin1, OUTPUT); pinMode(shoulderMotorPin2, OUTPUT); pinMode(shoulderMotorEnablePin, OUTPUT); digitalWrite(shoulderMotorEnablePin, HIGH); pinMode(elbowMotorPin1, OUTPUT); pinMode(elbowMotorPin2, OUTPUT); pinMode(elbowMotorEnablePin, OUTPUT); digitalWrite(elbowMotorEnablePin, HIGH); pinMode(wristMotorPin1, OUTPUT); pinMode(wristMotorPin2, OUTPUT); pinMode(wristMotorEnablePin, OUTPUT); digitalWrite(wristMotorEnablePin, HIGH); pinMode(handMotorPin1, OUTPUT); pinMode(handMotorPin2, OUTPUT); pinMode(handMotorEnablePin, OUTPUT); digitalWrite(handMotorEnablePin, HIGH); Serial.begin(9600); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if (incomingByte == 'Q') { digitalWrite(baseMotorPin1, LOW); digitalWrite(baseMotorPin2, HIGH); } if (incomingByte == 'W') { digitalWrite(baseMotorPin1, HIGH); digitalWrite(baseMotorPin2, LOW); } if (incomingByte == 'E') { digitalWrite(shoulderMotorPin1, LOW); digitalWrite(shoulderMotorPin2, HIGH); } if (incomingByte == 'R') { digitalWrite(shoulderMotorPin1, HIGH); digitalWrite(shoulderMotorPin2, LOW); } if (incomingByte == 'A') { digitalWrite(elbowMotorPin1, LOW); digitalWrite(elbowMotorPin2, HIGH); } if (incomingByte == 'S') { digitalWrite(elbowMotorPin1, HIGH); digitalWrite(elbowMotorPin2, LOW); } if (incomingByte == 'D') { digitalWrite(wristMotorPin1, LOW); digitalWrite(wristMotorPin2, HIGH); } if (incomingByte == 'F') { digitalWrite(wristMotorPin1, HIGH); digitalWrite(wristMotorPin2, LOW); } if (incomingByte == 'Z') { digitalWrite(handMotorPin1, LOW); digitalWrite(handMotorPin2, HIGH); } if (incomingByte == 'X') { digitalWrite(handMotorPin1, HIGH); digitalWrite(handMotorPin2, LOW); } if (incomingByte == 'O') { digitalWrite(baseMotorPin1, LOW); digitalWrite(baseMotorPin2, LOW); digitalWrite(shoulderMotorPin1, LOW); digitalWrite(shoulderMotorPin2, LOW); digitalWrite(elbowMotorPin1, LOW); digitalWrite(elbowMotorPin2, LOW); digitalWrite(wristMotorPin1, LOW); digitalWrite(wristMotorPin2, LOW); digitalWrite(handMotorPin1, LOW); digitalWrite(handMotorPin2, LOW); } } } [/code]
et voici l'erreur afficher :
'incomingByte' was not declared in this scope
sketch_nov28a.cpp: In function 'void loop()':
sketch_nov28a:44: error: 'incomingByte' was not declared in this scope
sketch_nov28a.cpp: In function 'void loop()':
sketch_nov28a:44: error: 'incomingByte' was not declared in this scope
Cordialement Dylan.
#347
Posté 28 novembre 2012 - 08:51
'incomingByte' was not declared in this scope
sketch_nov28a.cpp: In function 'void loop()':
sketch_nov28a:44: error: 'incomingByte' was not declared in this scope
sketch_nov28a.cpp: In function 'void loop()':
sketch_nov28a:44: error: 'incomingByte' was not declared in this scope
Salut.
Quelques questions :
- Que te dit l'erreur ?
- Que représente la notion de 'scope' en C/C++ ?
Si tu as la réponse à ces deux questions, tu devrais pouvoir comprendre l'erreur. Sinon, demande-toi :
- Comment utilise-t-on des variables en C/C++, Java, et une bonne partie des langages de programmation (donne un exemple) ?
#349
Posté 30 novembre 2012 - 01:19
Je pense que l'erreur veut dire que je n'est pas declarer IncomingByte dans void setup() , c'est ca non ?
Presque. Là, tu réponds à la première question : "incomingByte" n'a pas été déclaré, donc il n'est pas connu lorsque tu fais appel à lui. Maintenant, si tu réponds à la deuxième question, tu devrais comprendre en quoi la réponse que tu m'as faite est presque juste, et pas totalement juste.

#350
Posté 02 décembre 2012 - 04:45
int controls[13] = { 0x47, 0x67, 0x57, 0x77, 0x45, 0x65, 0x53, 0x73, 0x42, 0x62, 0x4c, 0x6c, 0x58 }; // Base int baseEnablePin = 3; int basePin1 = 16; int basePin2 = 17; // Shoulder int shoulderEnablePin = 14; int shoulderPin1 = 2; int shoulderPin2 = 4; // Elbow int elbowEnablePin = 6; int elbowPin1 = 7; int elbowPin2 = 15; // Wrist int wristEnablePin = 11; int wristPin1 = 8; int wristPin2 = 12; //Grip int gripEnablePin = 10; int gripPin1 = 9; int gripPin2 = 5; int ledPin = 13; // set a variable to store the byte sent from the serial port int incomingByte; void setup() { // set light LED pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // set the SN754410 pins as outputs: pinMode(basePin1, OUTPUT); pinMode(basePin2, OUTPUT); pinMode(baseEnablePin, OUTPUT); pinMode(shoulderPin1, OUTPUT); pinMode(shoulderPin2, OUTPUT); pinMode(shoulderEnablePin, OUTPUT); pinMode(elbowPin1, OUTPUT); pinMode(elbowPin2, OUTPUT); pinMode(elbowEnablePin, OUTPUT); pinMode(wristPin1, OUTPUT); pinMode(wristPin2, OUTPUT); pinMode(wristEnablePin, OUTPUT); pinMode(gripPin1, OUTPUT); pinMode(gripPin2, OUTPUT); pinMode(gripEnablePin, OUTPUT); // start sending data at 115200 baud rate // I set my Xbee Baud Rate at 115200 bps, // change the Baud Rate according to your XBee Serial.begin(115200); } void loop() { // check that there's something in the serial buffer if (Serial.available() > 0) { // read the byte and store it in our variable // the byte sent is actually an ascii value incomingByte = Serial.read(); // note the upper casing of each letter! // each letter turns a motor different way. //===== Grip // Grip in if (incomingByte == controls[0]) { gripIn(); } // Grip Out if (incomingByte == controls[1]) { gripOut(); } //Wrist if (incomingByte == controls[2]) { //digitalWrite(wristPin1, LOW); //digitalWrite(wristPin2, HIGH); wristUp(); } if (incomingByte == controls[3]) { wristDown(); } //===== Elbow // Elbow Up if (incomingByte == controls[4]) { elbowUp(); } // Elbow Down if (incomingByte == controls[5]) { elbowDown(); } //===== Shoulder // Shoulder Up if (incomingByte == controls[6]) { shoulderUp(); } // Shoulder Down if (incomingByte == controls[7]) { shoulderDown(); } //===== Base // Base Right if (incomingByte == controls[8]) { baseRight(); } // Base Left if (incomingByte == controls[9]) { baseLeft(); } // Light ON if (incomingByte == controls[10]) { digitalWrite(ledPin, HIGH); } // Light OFF if (incomingByte == controls[11]) { digitalWrite(ledPin, LOW); } // if a O is sent make sure the motors are turned off if (incomingByte == controls[12]) { allStop(); } delay(100); } } void gripIn() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, HIGH); } void gripOut() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin2, LOW); digitalWrite(gripPin1, HIGH); } void wristUp() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, HIGH); } void wristDown() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin2, LOW); digitalWrite(wristPin1, HIGH); } void elbowUp() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, HIGH); } void elbowDown() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin2, LOW); digitalWrite(elbowPin1, HIGH); } void shoulderUp() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, HIGH); } void shoulderDown() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin2, LOW); digitalWrite(shoulderPin1, HIGH); } void baseRight() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin1, LOW); digitalWrite(basePin2, HIGH); } void baseLeft() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin2, LOW); digitalWrite(basePin1, HIGH); } void allStop() { digitalWrite(baseEnablePin, LOW); digitalWrite(basePin1, LOW); digitalWrite(basePin2, LOW); digitalWrite(shoulderEnablePin, LOW); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, LOW); digitalWrite(elbowEnablePin, LOW); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, LOW); digitalWrite(wristEnablePin, LOW); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, LOW); digitalWrite(gripEnablePin, LOW); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, LOW); }
et avec ce code en Processing
// load the serial library for Processing import processing.serial.*; // instance of the serial class Serial port; // control commands array: // GripOut, GripIn, WristUp, WristDown, ElbowUp, ElbowDown, // ShoulderUp, shoulderDown, BaseCW, BaseCCW, LightOn, LightOff, Stop int[] controls = new int[] { 0x47, 0x67, 0x57, 0x77, 0x45, 0x65, 0x53, 0x73, 0x42, 0x62, 0x4c, 0x6c, 0x58 }; // Image button. // Loading images and using them to create a button. ImageButtons GripIn; ImageButtons GripOut; ImageButtons WristUp; ImageButtons WristDown; ImageButtons ElbowUp; ImageButtons ElbowDown; ImageButtons ShoulderUp; ImageButtons ShoulderDown; ImageButtons BaseCW; ImageButtons BaseCCW; ImageButtons LightOn; ImageButtons LightOff; ImageButtons Pause; // background PImage bg; // set the font PFont myFont; void controlGUI() { bg = loadImage("background.jpg"); background(bg); int buttonSize = 44; PImage selected = loadImage("controlSel.png"); //Grip In PImage gripInImage = loadImage("controlIn.png"); PImage gripInOver = loadImage("controlInOver.png"); GripIn = new ImageButtons(30, 83, buttonSize, buttonSize, gripInImage, gripInOver, selected); //Grip Out PImage gripOutImage = loadImage("controlOut.png"); PImage gripOutOver = loadImage("controlOutOver.png"); GripOut = new ImageButtons(78, 83, buttonSize, buttonSize, gripOutImage, gripOutOver, selected); //Wrist Up PImage wristUpImage = loadImage("controlUp.png"); PImage wristUpOver = loadImage("controlUpOver.png"); WristUp = new ImageButtons(150, 36, buttonSize, buttonSize, wristUpImage, wristUpOver, selected); //Wrist Down PImage wristDownImage = loadImage("controlDown.png"); PImage wristDownOver = loadImage("controlDownOver.png"); WristDown = new ImageButtons(198, 36, buttonSize, buttonSize, wristDownImage, wristDownOver, selected); //Elbow Up PImage elbowUpImage = loadImage("controlUp.png"); PImage elbowUpOver = loadImage("controlUpOver.png"); ElbowUp = new ImageButtons(258, 83, buttonSize, buttonSize, elbowUpImage, elbowUpOver, selected); //Elbow Down PImage elbowDownImage = loadImage("controlDown.png"); PImage elbowDownOver = loadImage("controlDownOver.png"); ElbowDown = new ImageButtons(306, 83, buttonSize, buttonSize, elbowDownImage, elbowDownOver, selected); //Shoulder Up PImage shoulderUpImage = loadImage("controlUp.png"); PImage shoulderUpOver = loadImage("controlUpOver.png"); ShoulderUp = new ImageButtons(208, 160, buttonSize, buttonSize, shoulderUpImage, shoulderUpOver, selected); //Shoulder Down PImage shoulderDownImage = loadImage("controlDown.png"); PImage shoulderDownOver = loadImage("controlDownOver.png"); ShoulderDown = new ImageButtons(256, 160, buttonSize, buttonSize, shoulderDownImage, shoulderDownOver, selected); //Base CW PImage baseCWImage = loadImage("controlCW.png"); PImage baseCWOver = loadImage("controlCWOver.png"); BaseCW = new ImageButtons(130, 234, buttonSize, buttonSize, baseCWImage, baseCWOver, selected); //Base CCW PImage baseCCWImage = loadImage("controlCCW.png"); PImage baseCCWOver = loadImage("controlCCWOver.png"); BaseCCW = new ImageButtons(178, 234, buttonSize, buttonSize, baseCCWImage, baseCCWOver, selected); //Light On PImage lightOnImage = loadImage("LightOn.png"); PImage lightOnOver = loadImage("LightOnOver.png"); LightOn = new ImageButtons(30, 184, buttonSize, buttonSize, lightOnImage, lightOnOver, selected); //Light Off PImage lightOffImage = loadImage("LightOff.png"); PImage lightOffOver = loadImage("LightOffOver.png"); LightOff = new ImageButtons(78, 184, buttonSize, buttonSize, lightOffImage, lightOffOver, selected); /* //Pause PImage pauseImage = loadImage("controlStop.png"); PImage pauseOver = loadImage("controlStopOver.png"); Pause = new ImageButtons(315, 215, buttonSize, buttonSize, pauseImage, pauseOver, selected); */ } void setup() { // List all the available serial ports in the output pane. // You will need to choose the port that the Arduino board is // connected to from this list. The first port in the list is // port #0 and the third port in the list is port #2. //println(Serial.list()); // Open the port that the Arduino board is connected to // (in this case #0) // Make sure to open the port at the same speed Arduino is // using (9600bps) //port = new Serial(this, Serial.list()[1], 9600); // On Window PC, use "Outgoing" of the bluetooth device //port = new Serial(this, "COM16", 115200); // And "Outgoing" port for FlyFly is COM27 //port = new Serial(this, "COM27", 9600); // This one for XBee port = new Serial(this, "COM30", 115200); // screen size of the program //size(145, 455); size(400, 300); smooth(); // test ellipse ellipseMode(RADIUS); textFont(createFont("Verdana", 14)); controlGUI(); } void updateDisplay() { GripIn.update(); GripIn.display(); GripOut.update(); GripOut.display(); WristUp.update(); WristUp.display(); WristDown.update(); WristDown.display(); ElbowUp.update(); ElbowUp.display(); ElbowDown.update(); ElbowDown.display(); ShoulderUp.update(); ShoulderUp.display(); ShoulderDown.update(); ShoulderDown.display(); BaseCW.update(); BaseCW.display(); BaseCCW.update(); BaseCCW.display(); LightOn.update(); LightOn.display(); LightOff.update(); LightOff.display(); //Pause.update(); //Pause.display(); } //Send Commands void sendCommands() { // Grip if(GripIn.pressed) { port.write(controls[0]); //println("Grip In: " + (char)controls[0]); } if(GripOut.pressed) { port.write(controls[1]); //println("Grip Out: " + (char)controls[1]); } if(mouseX > 30 && mouseX < 129 && mouseY > 51 && mouseY < 79) { port.write(controls[12]); //println("Grip Stop! " + (char)controls[12]); } // Wrist if(WristUp.pressed) { port.write(controls[2]); //println("Wrist Up: " + (char)controls[2]); } if(WristDown.pressed) { port.write(controls[3]); //println("Wrist Down: " + (char)controls[3]); } if(mouseX > 148 && mouseX < 248 && mouseY > 5 && mouseY < 33) { port.write(controls[12]); //println("Wrist Stop! " + (char)controls[12]); } // Elbow if(ElbowUp.pressed) { port.write(controls[4]); //println("Elbow Up: " + (char)controls[4]); } if(ElbowDown.pressed) { port.write(controls[5]); //println("Elbow Down: " + (char)controls[5]); } if(mouseX > 258 && mouseX < 358 && mouseY > 51 && mouseY < 79) { port.write(controls[12]); //println("Elbow Stop! " + (char)controls[12]); } //Shoulder if(ShoulderUp.pressed) { port.write(controls[6]); //println("Shoulder Up: " + (char)controls[6]); } if(ShoulderDown.pressed) { port.write(controls[7]); //println("Shoulder Down: " + (char)controls[7]); } if(mouseX > 208 && mouseX < 308 && mouseY > 130 && mouseY < 158) { port.write(controls[12]); //println("Shoulder Stop! " + (char)controls[12]); } // Base if(BaseCW.pressed) { port.write(controls[8]); //println("Base Rotate CW: " + (char)controls[8]); } if(BaseCCW.pressed) { port.write(controls[9]); //println("Base Rotate CCW: " + (char)controls[9]); } if(mouseX > 130 && mouseX < 230 && mouseY > 202 && mouseY < 230) { port.write(controls[12]); //println("Base Stop! " + (char)controls[12]); } // Light if(LightOn.pressed) { port.write(controls[10]); //println("Light On: " + (char)controls[10]); } if(LightOff.pressed) { port.write(controls[11]); //println("Light Off: " + (char)controls[11]); } /* if(Pause.pressed) { //port.write(controls[12]); println("CStop: " + (char)controls[12]); } */ } void draw() { updateDisplay(); sendCommands(); } // Button & ImageButtons Classes class Button { int x, y; int w, h; color basecolor, highlightcolor; color currentcolor; boolean over = false; boolean pressed = false; void pressed() { if(over && mousePressed) { pressed = true; } else { pressed = false; } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } } class ImageButtons extends Button { PImage base; PImage roll; PImage down; PImage currentimage; ImageButtons(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown) { x = ix; y = iy; w = iw; h = ih; base = ibase; roll = iroll; down = idown; currentimage = base; } void update() { over(); pressed(); if(pressed) { currentimage = down; } else if (over){ currentimage = roll; } else { currentimage = base; } } void over() { if( overRect(x, y, w, h) ) { over = true; } else { over = false; } } void display() { image(currentimage, x, y); } }
Le seul probleme c'est le code processing , quand je le met en route il me met une erreur ! que voici :
error inside Serial.Write()
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
java.lang.NullPointerException
at processing.serial.Serial.write(Unknown Source)
at sketch_121202a.sendCommands(sketch_121202a.java:261)
at sketch_121202a.draw(sketch_121202a.java:322)
at processing.core.PApplet.handleDraw(PApplet.java:2128)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:190)
at processing.core.PApplet.run(PApplet.java:2006)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.write()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.write(Unknown Source)
at sketch_121202a.sendCommands(sketch_121202a.java:261)
at sketch_121202a.draw(sketch_121202a.java:322)
at processing.core.PApplet.handleDraw(PApplet.java:2128)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:190)
at processing.core.PApplet.run(PApplet.java:2006)
at java.lang.Thread.run(Thread.java:662)
J'ai compris que l'erreur venait de Serial.Write , mais ou ??
Cordialement Dylan.
#351
Posté 02 décembre 2012 - 07:24
Mon code fonctionne ! je trouve ca bizarre puisque je n'ai rien modifier ! bon bah le principal c'est qui marche. Mais j'ai un autre code qui me semble bon. EDIT : je viens de le tester et il est bon !
Méfies-toi, un code qui fonctionne d'un coup cache souvent d'autres bugs qui viendront t'embêter plus tard !
Pour ton erreur Java, on dirait qu'il y a un problème de pointeur qui est NULL et du coup, les fonctions suivantes n'arrivent pas à s'exécuter puisse qu'ils leur manquent une info. Mets les fichiers associés à ta source qu'on puisse tester le code.
#352
Posté 02 décembre 2012 - 10:27
Cordialement Dylan.
#353
Posté 04 janvier 2013 - 02:22
Bon la je vais avoir besoin de votre aide ! car aujourd'hui mon professeur de technologie nous a annoncer que nous allons realiser un robot comme projet et qui comptera pour notre BAC. Ensuite il a dit que si on voulait ( ceux qui etait interesse) pouvaient realiser un robot chez eux et ensuite le ramener a l'ecole pour recevoir une note !! Donc j'ai jusqu'en Avril pour finir mon robot que j'ai deja commence. Mais malheureusement je fais du sur place , d'un cote avec le code de la pince que je n'arrive pas a trouver l'erreur et l'autre avec le module Bluetooth et les servomoteurs toujours pas acheter.
Est ce que quelqu'un pourrais m'eclairer pour mon code qui ne fonctionne pas ? j'ai une erreur dans processing , mais ou ca ?
Je vous remerci d'avance esperant avoir des reponses rapidement.
Bonne soiree a tous !
Cordialement Dylan.
#354
Posté 04 janvier 2013 - 02:52
"java.lang.NullPointerException
at processing.serial.Serial.write(Unknown Source)"
L'erreur vient de ta liaison série avec le bras. Décris-nous le procédé que tu suis pour faire fonctionner ton robot : allumage du bras, lancement de l'appli de contrôle, etc. À mon avis, l'erreur se produit parce que tu lances ton appli alors que le bras n'est pas connecté au PC.
#355
Posté 06 janvier 2013 - 10:43
tout d'abord j'utilise mes 3 L293D pour controler mes 5 moteurs (la pince) apres avoir connecter les L293D sur ma carte arduino , je connecte le cable USB a mon PC.
Je copie le code dans l'interface Arduino. Puis je l'upload sur ma carte.
Je lance ensuite le logiciel Processing avec le code Processing (la pince est toujours au PC connecter) , je lance le code et la je vois une fenetre qui s'ouvre avec en image de fond la pince que j'utilise (photo syle dessin au crayon) et plusieurs boutons : base , poignee , pince , coude , ..... et les fleches pour les directions.
quand je clique sur une de ces fleches l'erreur se produit.
Cordialement Dylan.
#357
Posté 05 avril 2016 - 08:37
Déterrage de topic en bonne et dur forme... et en plus pour poster un message totalement inutile !
Venant d'un nouveau membre qui ne s'est pas présenté dans la rubrique adéquate et qui en plus à mis un lien vers sa webradio dans son profil, c'est un coup pour se faire bloquer son compte direct !
Pour la modération.
Mon site internet : http://ferdinandpiette.com/
Répondre à ce sujet

2 utilisateur(s) li(sen)t ce sujet
0 members, 2 guests, 0 anonymous users