Aller au contenu


Photo
- - - - -

Code de mon robot


  • Veuillez vous connecter pour répondre
81 réponses à ce sujet

#41 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 24 mai 2012 - 09:38

oui je sais , mais comme j'avais regarder le tutoriel et que eux utilise un Servomoteur , alors j'ai fais pareil mais avec deux , et je voulais savoir si il était correcte. A présent je vais rajouter le contrôle par Clavier , mais j'ai une question :

comme la je vais utiliser des servomoteurs et que j'ai choisi dans la librairie "#include<Servo.h> je peux toujours utilise le même système que pour les moteurs ? c'est adire comme ceci :

if (incomingByte == '8') {        // chiffre 8 represente l'action de rouler tout droit
    digitalWrite(SERVO1, HIGH);   
    digitalWrite(SERVO2, HIGH);  


Ou je dois mettre quelque chose d'autre a la place de digitalWrite ou a la place de HIGH ?
Merci a tous
Cordialement Dylan.

#42 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

  • Membres
  • PipPipPipPipPip
  • 1 193 messages
  • Location:https://t.me/pump_upp
  • Interests:https://t.me/pump_upp

Posté 25 mai 2012 - 09:38

Non tu doit gardé la fonction #include<Servo.h> , c'est le plus simple

#43 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 09:57

non ca je sais , mais a la place de DigitalWrite , je dois pas mettre quelque chose d'autre a la place , et a la place HIGH je dois pas mettre la pulsion désiré ?
Merci a tous
Cordialement Dylan.

#44 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 10:03

comme ca ? :

#include <Servo.h>


 const int SERVO1=11;
 const int SERVO2=12;

 int ReceptionOctet=0; 
 int ReceptionNombre=0; 
 int impulsion=1500; 
 
 Servo servo_1;
 Servo servo_2;
 

 void setup()   { 

 servo_1.attach(SERVO1);  
 servo_2.attach(SERVO2);

 Serial.begin(115200); 

 pinMode(SERVO1, OUTPUT);
 pinMode(SERVO2, OUTPUT);


 }

 void loop(){

 f (Serial.available() > 0) {
    incomingByte = Serial.read();
   
    if (incomingByte == '8') {
    digitalWrite(servo_1, HIGH);   
    digitalWrite(servo_2, HIGH);  
    } 
    if (incomingByte == '2') {
    digitalWrite(servo_1, LOW);   
    digitalWrite(servo_2, LOW);  // comment faire pour qu'il aille en arriere ???
    }
    if (incomingByte == '4') {
    digitalWrite(servo_1, LOW);   
    digitalWrite(servo_2, HIGH);  
    } 
    if (incomingByte == '6') {
    digitalWrite(servo_1, HIGH);   
    digitalWrite(servo_2, LOW);  
    }
    if (incomingByte == 'O') {
    digitalWrite(servo_1, LOW);   
    digitalWrite(servo_1, LOW);  
    digitalWrite(servo_2, LOW);   
    digitalWrite(servo_2, LOW); 
    }
  }
}
  

Merci a tous
Cordialement Dylan.

#45 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

  • Membres
  • PipPipPipPipPip
  • 1 193 messages
  • Location:https://t.me/pump_upp
  • Interests:https://t.me/pump_upp

Posté 25 mai 2012 - 10:57

Aisé avec les fonction false et true ,a la place de LOW et HIGH .

Désolé je n'est pas trop le tant de testé , car je suis sur visual basic.

#46 julkien

julkien

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 032 messages
  • Gender:Male

Posté 25 mai 2012 - 11:58

car je suis sur visual basic.


tu titilles ma curieusité???

#47 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 12:22

#include <Servo.h>





 const int SERVO1=11;

 const int SERVO2=12;



 int ReceptionOctet=0; 

 int ReceptionNombre=0; 

 int impulsion=1500; 

 

 Servo servo_1;

 Servo servo_2;

 



 void setup()   { 



 servo_1.attach(SERVO1);  

 servo_2.attach(SERVO1);



 Serial.begin(115200); 



 pinMode(SERVO1, OUTPUT);

 pinMode(SERVO2, OUTPUT);





 }



 void loop(){



 f (Serial.available() > 0) {

    incomingByte = Serial.read();

   

    if (incomingByte == '8') {

    digitalWrite(servo_1, TRUE);   

    digitalWrite(servo_1, TRUE);  

    } 

    if (incomingByte == '2') {

    digitalWrite(servo_1, FALSE);   

    digitalWrite(servo_1, FALSE);  // comment faire pour qu'il aille en arriere ???

    }

    if (incomingByte == '4') {

    digitalWrite(servo_1, FALSE);   

    digitalWrite(servo_1, TRUE);  

    } 

    if (incomingByte == '6') {

    digitalWrite(servo_1, TRUE);   

    digitalWrite(servo_1, FALSE);  

    }

    if (incomingByte == '5') {

    digitalWrite(servo_1, FALSE);   

    digitalWrite(servo_1, FALSE);  

    } 

    if (incomingByte == 'O') {

    digitalWrite(servo_1, FALSE);   

    digitalWrite(servo_1, FALSE);  

    digitalWrite(servo_2, FALSE);   

    digitalWrite(servo_2, FALSE); 

    }

  }

}

  


Merci a tous
Cordialement Dylan.

#48 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

  • Membres
  • PipPipPipPipPip
  • 1 193 messages
  • Location:https://t.me/pump_upp
  • Interests:https://t.me/pump_upp

Posté 25 mai 2012 - 12:36

car je suis sur visual basic.


Et bien je me remet dessus ( visual basic ) je veux en savoir plus.

Donc en se moment j’apprends a créé une page Web sur google , pas facile.

Pourquoi une page Web , juste parce que je veux évoluer dans se mode visual basic , et je suis curieux.

#49 julkien

julkien

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 032 messages
  • Gender:Male

Posté 25 mai 2012 - 12:43

Et bien je me remet dessus ( visual basic ) je veux en savoir plus.

Donc en se moment j'apprends a créé une page Web sur google



un explorateur tu veux dire ?

#50 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

  • Membres
  • PipPipPipPipPip
  • 1 193 messages
  • Location:https://t.me/pump_upp
  • Interests:https://t.me/pump_upp

Posté 25 mai 2012 - 01:19

Oui c'est bien ça un ( explorateur ).

#51 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 01:40

Heu .... et le code ? :P :P :P
Merci a tous
Cordialement Dylan.

#52 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

  • Membres
  • PipPipPipPipPip
  • 1 193 messages
  • Location:https://t.me/pump_upp
  • Interests:https://t.me/pump_upp

Posté 25 mai 2012 - 01:46

le code il et pas bon , mes pas du tous j'ai été a coté de la plaque moi , désolé.

#include <SoftwareServo.h>

SoftwareServo servo1;
SoftwareServo servo2;

void setup()
{
  
  servo1.attach(2);
  servo1.setMaximumPulse(2200);
  servo2.attach(4);
  servo2.setMaximumPulse(2200);
  Serial.begin(9600);
  Serial.print("Ready");
}

void loop()
{
  static int value = 0;
  static char CurrentServo = 0;

  if ( Serial.available()) {
    char ch = Serial.read();
    switch(ch) {
      case 'A':
        servo1.attach(2);
        CurrentServo='A';
        digitalWrite(2,LOW);
        break;
      case 'B':
        servo2.attach(2);
        CurrentServo='Z';
        digitalWrite(2,HIGH);
        break;
       case 'Q':
        servo1.attach(4);
        CurrentServo='Q';
        digitalWrite(4,LOW);
        break;
      case 'S':
        servo2.attach(4);
        CurrentServo='S';
        digitalWrite(4,HIGH);
        break;
        
      case '0' ... '9':
        value=(ch-'0')*20;
        if (CurrentServo=='A')
        {
          servo1.write(value);
        }
        else if (CurrentServo=='B')
        {
          servo2.write(value);
        }
        break;
        
                if (CurrentServo=='Q')
        {
          servo1.write(value);
        }
        else if (CurrentServo=='S')
        {
          servo2.write(value);
        }
        break;
    }
  }
  SoftwareServo::refresh();
}

celui la devrais correspond.

#53 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 04:50

a oui en effet , ce n'est aucun rapport avec le mien , et il y'a plein de nom que je ne connais pas (Software , static , current) .
Merci a tous
Cordialement Dylan.

#54 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 25 mai 2012 - 04:53

Heu ... quand je fais , RUN il y'a un message d'erreur qui apparait en bas en orange , qui dit :" 'SoftwareServo' does not name a type "
Merci a tous
Cordialement Dylan.

#55 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 27 mai 2012 - 08:14

Pour quoi cette erreur survient ?
Merci a tous
Cordialement Dylan.

#56 rbot99

rbot99

    Membre passionné

  • Membres
  • PipPipPip
  • 514 messages
  • Gender:Male

Posté 27 mai 2012 - 08:43

tu peux apprendre arduino plus simplement et sans base sur : http://sciences.siteduzero.com/tutoriel-3-515617-le-langage-arduino-1-2.html
moi j'ai appris en deux jours et maintenant je sais programmer!!
cordialement
rbot99
ps: tu n'as besoin d'aucune connaissance pour devenir bon en prog et j'en suis la preuve vivante! ^_^
N'entretiens pas l'espoir de ce qui ne peut être espéré , Pythagore

#57 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 27 mai 2012 - 10:27

Oui je connais ce lien et j'apprends dessus , merci . Mais comme Seb03000 me l' a envoyer je me suis dis peut être qu'il y un problème chez moi ou peut être que cela est son code.
Merci a tous
Cordialement Dylan.

#58 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 28 mai 2012 - 04:55

Voila quelques morceaux de codes Processing colles et modifier :

 
// load the serial library for Processing
import processing.serial.*; 
// instance of the serial class
Serial port;
// values to store X, Y for each button
int M1LX, M1RX, M2LX, M2RX, M3LX, M3RX, M4LX, M4RX, M5LX, M5RX;
int M1LY, M1RY, M2LY, M2RY, M3LY, M3RY, M4LY, M4RY, M5LY, M5RY;
// stores the width/height of the box
int boxSize = 64;
// 2 new instances of my arrow class
// also set an array of coordinates for each arrow
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};
// set the font
PFont myFont;
 
void setup()  {
  // screen size of the program
  size(145, 455);
  // set the coordinates of each button box
  // base motor M1LX = Motor 1 Left X  etc..
  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;
  // Main motor
  M5LX = 5;
  M5LY = 385;
  M5RX = 75;
  M5RY = 385;
   // Tout droit
  M5LX = 5;
  M5LY = 475;
  M5RX = 75;
  M5RY = 475;
   // Arriere
  M5LX = 5;
  M5LY = 565;
  M5RX = 75;
  M5RY = 565; 
  // Gauche
  M5LX = 5;
  M5LY = 655;
  M5RX = 75;
  M5RY = 655; 
  // Droite
  M5LX = 5;
  M5LY = 745;
  M5RX = 75;
  M5RY = 7455;
 
  // 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()); 
  // set the font to use
  myFont = createFont("verdana", 12);
  textFont(myFont);
  // 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); 
  // create the base arrow
  myRightArrow = new arrow(rightArrowxpoints,rightArrowypoints,7);
  myLeftArrow = new arrow(leftArrowxpoints,leftArrowypoints,7);
}
 
void draw() 
{ 
  background(0);
  noStroke();
  fill(150);
  // draw each box/ button with a label above each    
  text("Base Moteur (Q/W)", 5, 5, 200, 75); 
  text("Epaule Moteur (E/R)", 5, 95, 200, 75);
  text("Coude Motor (A/S)", 5, 185, 200, 75);
  text("Poignee Motor (D/F)", 5, 275, 200, 75);     
  text("Main Motor (Z/X)", 5, 365, 200, 75);
  text("Tout droit_marche arriere (8/2)", 5, 365, 200, 75);
  text("gauche_droite (4/6)", 5, 365, 200, 75);
 
  // start looking to see whats pressed and send a value
  // over the serial port
  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');
    }
    if (key == '8' || key == '8') {
      port.write('8');
    }
    if (key == '2' || key == '2') {
      port.write('2');
    }
    if (key == '4' || key == '4') {
      port.write('4');
    }
    if (key == '4' || key == '4') {
      port.write('4');
    }
  } 
  
  // if no key is pressed check to see if the mouse button is pressed
  else if (mousePressed == true) {
    // check to see if the mouse is inside each box/ button if so send the value
    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 if(mouseX > M5RX-boxSize && mouseX < M5RX+boxSize && 
      mouseY > M5RY-boxSize && mouseY < M5RY+boxSize) {
        port.write('8');
   }     
        else if(mouseX > M5RX-boxSize && mouseX < M5RX+boxSize && 
      mouseY > M5RY-boxSize && mouseY < M5RY+boxSize) {
        port.write('2');
   }
    
    else if(mouseX > M5RX-boxSize && mouseX < M5RX+boxSize && 
      mouseY > M5RY-boxSize && mouseY < M5RY+boxSize) {
        port.write('4');
   }
    
    else if(mouseX > M5RX-boxSize && mouseX < M5RX+boxSize && 
      mouseY > M5RY-boxSize && mouseY < M5RY+boxSize) {
        port.write('6');
   }
    else {
      // if the mouse is pressed but not with in a box make sure nothings moving
      port.write('O');   
    } 
  } else {
    // no key or mouse press then make sure nothings moving.
    port.write('O');   
  } 
 
  // draw the buttons
  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 { 
  /* our class is basically an instance of java.awt.Polygons and this class expects and array of X points, Y points and the number of 
     points in our shape. The variable names also have to be direct references to what this class expects, so xpoints, ypoints and npoints are all
     set/defined in the java class.
  */
  public arrow(int[] xpoints,int[] ypoints, int npoints) {
    // super invokes the java.awt.Polygon class
    super(xpoints,ypoints,npoints);
 
  } 
    // supply offsets to draw the arrow, means I don't need to set points for each one
    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();
    }
}

Merci a tous
Cordialement Dylan.

#59 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 31 mai 2012 - 04:05

Pour le bluetooth , j'ai trouver ceci :

#include <SoftwareSerial.h>

 SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
   // Open serial communications and wait for port to open:
   Serial.begin(57600);
   while (!Serial) {
     ; // wait for serial port to connect. Needed for Leonardo only
   }


   Serial.println("Goodnight moon!");

   // set the data rate for the SoftwareSerial port
   mySerial.begin(4800);
   mySerial.println("Hello, world?");
}

void loop() // run over and over
{
   if (mySerial.available())
     Serial.write(mySerial.read());
   if (Serial.available())
     mySerial.write(Serial.read());
}

Merci a tous
Cordialement Dylan.

#60 julkien

julkien

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 032 messages
  • Gender:Male

Posté 31 mai 2012 - 05:00

tu peux apprendre arduino plus simplement et sans base sur : http://sciences.site...rduino-1-2.html moi j'ai appris en deux jours et maintenant je sais programmer!! cordialement rbot99 ps: tu n'as besoin d'aucune connaissance pour devenir bon en prog et j'en suis la preuve vivante! ^_^


heu sa va les chevilles?
franchement tu exagere pas du tout, maintenant tu es un expert ?!
:laugh1: :kez_11: :dash2: :bad:
franchement patétique le bleu
je suis partie de rien moi aussi et je bricole encore pas mal et je n'arrive pas encore a dire : je suis bon en programmation!
alors toi qui jusqu'a present, donne que des lien qui n'aide pas vraiment(pour la plus part) et qui n'a jamais vraiment plublier le moindre bout de code....




0 utilisateur(s) li(sen)t ce sujet

0 members, 0 guests, 0 anonymous users