Aller au contenu


Photo
- - - - -

Code de mon robot


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

#61 Esprit

Esprit

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 503 messages
  • Gender:Male
  • Location:Belgique

Posté 31 mai 2012 - 09:31

Je résiste plus à utiliser l'un des nouveaux smiley.

:tatice_03:

Il y a des gens qui font de la programmation pendant 10 ans et qui n'osent pas se vanter d'être "bons". Mais toi, tu es devenu un bon programmeur en deux jours... Oui oui oui môssieur. Je m'incline. :thank_you:

Sinon, tu peux nous faire un asservissement PID en vitesse et en position sur un robot à roues ?
Ou nous programmer un p'tit truc pour qu'un hexapode apprenne à marcher tout seul ?
Que dirais-tu d'un peu de reconnaissance d'image ? J'aimerais scanner des documents manuscrits et que mon ordinateur retranscrive tout dans un beau document. Puis qu'il me corrige mes fautes d'orthographe, évidemment.

Autre chose ? Bah oui, dans une semaine quand tu auras fait tout ça, j'en aurai d'autres à proposer.

Esprit
*Rêve d'en caser un dans un robot*


#62 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 01 juin 2012 - 08:37

Pour mon code , quelqu'un pourrait me dire s'il est bon ??
Merci a tous
Cordialement Dylan.

#63 Esprit

Esprit

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 503 messages
  • Gender:Male
  • Location:Belgique

Posté 01 juin 2012 - 09:36

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 "


C'est parce que tu n'as pas la librairie "SoftwareServo".

Esprit
*Rêve d'en caser un dans un robot*


#64 Esprit

Esprit

    Pilier du forum

  • Membres
  • PipPipPipPipPip
  • 1 503 messages
  • Gender:Male
  • Location:Belgique

Posté 01 juin 2012 - 09:39

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.


Tu peux peut-être expliquer ce que ton code est censé faire ? Parce qu'il y a des erreurs et des choses qu'il ne fera jamais. Genre ;
        else if (CurrentServo=='B')
        {
          servo2.write(value);
        }

Il vaut jamais 'B'.

Esprit
*Rêve d'en caser un dans un robot*


#65 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

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

Posté 01 juin 2012 - 11:14

C'est parce que tu n'as pas la librairie "SoftwareServo".


comme Esprit te la dit il te faut la librairie.

je te les dis par MP , et je ne c'est pas combien de fois qu'il te falais la librairie SoftwareServo , je t'avais même passé

un liens que javais uploader , et je t'avais expliquer comment le placé dans ta lib de ton logiciel Arduino.

#66 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 01 juin 2012 - 02:02

Oui j'ai fais comme tu me l'as dit , mais je l'ai deja . J'ai le même nom de fichier dans la librairie

EDIT : tu m'as donner un lien avec un fichier "SoftwareSerial" et non pas comme l' a dit Esprit "SoftwareServo" .
Merci a tous
Cordialement Dylan.

#67 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

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

Posté 01 juin 2012 - 04:21

Alors excuse moi mes la lib SoftwareSerial et SoftwareServo c'est la même.

#68 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 01 juin 2012 - 05:02

Bah écoute je viens de supprimer dans la librairie SoftwareSerial que j'avais et je viens de le remplacer par celui que tu m'avais donner. Mais le problème reste toujours le même .
Merci a tous
Cordialement Dylan.

#69 rbot99

rbot99

    Membre passionné

  • Membres
  • PipPipPip
  • 514 messages
  • Gender:Male

Posté 02 juin 2012 - 05:30

c'est vrai je me rendait pas compte et ait mal mesuré mes mots mais avoue que c'est pas mal pour commencer non? :Alex_01:

Je résiste plus à utiliser l'un des nouveaux smiley.

:tatice_03:

Il y a des gens qui font de la programmation pendant 10 ans et qui n'osent pas se vanter d'être "bons". Mais toi, tu es devenu un bon programmeur en deux jours... Oui oui oui môssieur. Je m'incline. :thank_you:

Sinon, tu peux nous faire un asservissement PID en vitesse et en position sur un robot à roues ?
Ou nous programmer un p'tit truc pour qu'un hexapode apprenne à marcher tout seul ?
Que dirais-tu d'un peu de reconnaissance d'image ? J'aimerais scanner des documents manuscrits et que mon ordinateur retranscrive tout dans un beau document. Puis qu'il me corrige mes fautes d'orthographe, évidemment.

Autre chose ? Bah oui, dans une semaine quand tu auras fait tout ça, j'en aurai d'autres à proposer.


N'entretiens pas l'espoir de ce qui ne peut être espéré , Pythagore

#70 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 05 juin 2012 - 09:33

Salut a tous ,

J'ai ce morceau de code pour le Bluetooth :

char val;         // variable to receive data from the serial port
int ledpin = 2;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin = 13, OUTPUT);  // pin 13 (on-board LED) as OUTPUT
 
  Serial.begin(115200);       // start serial communication at 115200bps
 
}
 
void loop() {
  if( Serial.available() )       // if data is available to read
  {;}
    val = Serial.read();         // read it and store it in 'val'
 
  if( val == '0' )               // if '0' was received led 13 is switched off

  {
   digitalWrite(ledpin, LOW);    // turn Off pin 13 off
delay(1000);                  // waits for a second   
Serial.println("13 off");
  }

if( val == '1' )               // if '1' was received led 13 on
 {
    digitalWrite(ledpin = 13, HIGH);  // turn ON pin 13 on
    delay(1000);                  // waits for a second
    Serial.println("13 on");
  }
}

ce code ne permet que d'allumer une LED. Comment faire pour mettre a la place tout mon code ?
Merci a tous
Cordialement Dylan.

#71 swolf

swolf

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 626 messages
  • Gender:Male

Posté 05 juin 2012 - 10:22

Salut a tous ,

J'ai ce morceau de code pour le Bluetooth :

char val;     	// variable to receive data from the serial port
int ledpin = 2;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin = 13, OUTPUT);  // pin 13 (on-board LED) as OUTPUT
 
  Serial.begin(115200);   	// start serial communication at 115200bps
 
}
 
void loop() {
  if( Serial.available() )   	// if data is available to read
  {;}
    val = Serial.read();     	// read it and store it in 'val'
 
  if( val == '0' )           	// if '0' was received led 13 is switched off

  {
   digitalWrite(ledpin, LOW);    // turn Off pin 13 off
delay(1000);                  // waits for a second   
Serial.println("13 off");
  }

if( val == '1' )           	// if '1' was received led 13 on
 {
    digitalWrite(ledpin = 13, HIGH);  // turn ON pin 13 on
    delay(1000);                  // waits for a second
    Serial.println("13 on");
  }
}

ce code ne permet que d'allumer une LED. Comment faire pour mettre a la place tout mon code ?


c'est juste une lecture du port série (serial.read) donc il suffit que tu change ta condition et son contenu...
Notre blog, à FJprod et moi: http://2froblog.wordpress.com/

#72 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 06 juin 2012 - 09:40

Comme ceci ?

char val;         // variable to receive data from the serial port

int baseMoteurEnablePin = 22;
int baseMoteurPin1 = 2;                             
int baseMoteurPin2 = 3;                           
int epauleMoteurEnablePin = 23;
int epauleMoteurPin1 = 4;                             
int epauleMoteurPin2 = 5; 
int coudeMoteurEnablePin = 24;
int coudeMoteurPin1 = 6;                             
int coudeMoteurPin2 = 7;                           
int poigneeMotorEnablePin = 25;
int poigneeMotorPin1 = 8;                             
int poigneeMotorPin2 = 9; 
int pinceMotorEnablePin = 26;
int pinceMotorPin1 = 10;                             
int pinceMotorPin2 = 11; 
int incomingByte;

#include <Servo.h>
Servo servo1;            // créer un objet d'asservissement pour commander le servo1
Servo servo2;           // créer un objet d'asservissement pour commander le servo2
int possition1 ;      // variable pour stocker la position1 d'asservissement
int possition2 = 90; //variable pour stocker la position2 d'asservissement
int current;      //conserver la trace de la position actuelle du servo
int codeValue;   //les code de la télécommande

void setup()
{
   // set the L293D pins as outputs:
  pinMode(baseMoteurPin1, OUTPUT);
  pinMode(baseMoteurPin2, OUTPUT);
  pinMode(baseMoteurEnablePin, OUTPUT);
  digitalWrite(baseMoteurEnablePin, HIGH);
  pinMode(epauleMoteurPin1, OUTPUT);
  pinMode(epauleMoteurPin2, OUTPUT);
  pinMode(epauleMoteurEnablePin, OUTPUT);
  digitalWrite(epauleMoteurEnablePin, HIGH);
  pinMode(coudeMoteurPin1, OUTPUT);
  pinMode(coudeMoteurPin2, OUTPUT);
  pinMode(coudeMoteurEnablePin, OUTPUT);
  digitalWrite(coudeMoteurEnablePin, HIGH);
  pinMode(poigneeMotorPin1, OUTPUT);
  pinMode(poigneeMotorPin2, OUTPUT);
  pinMode(poigneeMotorEnablePin, HIGH);
  pinMode(pinceMotorPin1, OUTPUT);
  pinMode(pinceMotorPin2, OUTPUT);
  pinMode(pinceMotorEnablePin, OUTPUT);
  digitalWrite(pinceMotorEnablePin, HIGH);
  
 servo1.attach(12);              // attache le servo sur la broche 7 à l'objet d'asservissement
 servo1.write(possition1);     // mis en position1 de départ servo1
 servo2.attach(13);            // attache le servo sur la broche 6 à l'objet d'asservissement
 servo2.write(possition2);   // mis en position2 de départ servo
 
 Serial.begin(115200);       // start serial communication at 115200bps
 
}
 
void loop() {
  if( Serial.available() )       // if data is available to read
  {;}
    val = Serial.read();         // read it and store it in 'val'
    // 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!
    // diferrent lettre pour les directions.
    if (incomingByte == 'Q') {
    digitalWrite(baseMoteurPin1, LOW);   
    digitalWrite(baseMoteurPin2, HIGH);  
    } 
    if (incomingByte == 'W') {
    digitalWrite(baseMoteurPin1, HIGH);   
    digitalWrite(baseMoteurPin2, LOW);  
    }
    if (incomingByte == 'E') {
    digitalWrite(epauleMoteurPin1, LOW);   
    digitalWrite(epauleMoteurPin2, HIGH);  
    } 
    if (incomingByte == 'R') {
    digitalWrite(epauleMoteurPin1, HIGH);   
    digitalWrite(epauleMoteurPin2, LOW);  
    }
    if (incomingByte == 'A') {
    digitalWrite(coudeMoteurPin1, LOW);   
    digitalWrite(coudeMoteurPin2, HIGH);  
    } 
    if (incomingByte == 'S') {
    digitalWrite(coudeMoteurPin1, HIGH);   
    digitalWrite(coudeMoteurPin2, LOW);  
    }
    if (incomingByte == 'D') {
    digitalWrite(poigneeMotorPin1, LOW);   
    digitalWrite(poigneeMotorPin2, HIGH);  
    } 
    if (incomingByte == 'F') {
    digitalWrite(poigneeMotorPin1, HIGH);   
    digitalWrite(poigneeMotorPin2, LOW);  
    }
    if (incomingByte == 'Z') {
    digitalWrite(pinceMotorPin1, LOW);   
    digitalWrite(pinceMotorPin2, HIGH);  
    } 
    if (incomingByte == 'X') {
    digitalWrite(pinceMotorPin1, HIGH);   
    digitalWrite(pinceMotorPin2, LOW);  
    }
    // si O est envoyer les moteurs ne s'allumeront pas (OFF)
    if (incomingByte == 'O') {
    digitalWrite(baseMoteurPin1, LOW);   
    digitalWrite(baseMoteurPin2, LOW);  
    digitalWrite(epauleMoteurPin1, LOW);   
    digitalWrite(epauleMoteurPin2, LOW); 
    digitalWrite(coudeMoteurPin1, LOW);   
    digitalWrite(coudeMoteurPin2, LOW);  
    digitalWrite(poigneeMotorPin1, LOW);   
    digitalWrite(poigneeMotorPin2, LOW); 
    digitalWrite(pinceMotorPin1, LOW);   
    digitalWrite(pinceMotorPin2, LOW); 
    }
  }
  {
 int x,delay_en;
 char val;
 while(1)
{
 val = Serial.read();
 if(val!=-1)
{
 switch(val)
{
 case '8':
 current  +=80;
 if (current > 180) current = 0;
 servo1.write(current);
 break;

 case '2':
 current -=80;
 if (current < 0) current = 180;
 servo1.write(current);
 break;

 case '4':
 current +=40;
 if (current > 180) current = 0;
 servo2.write(current);
 break;

 case '6':
 current -=40;
 if (current < 0) current = 180;
 servo2.write(current);
 break;

 int sensorValue = analogRead(1); // analogique 1, a 10k
 while (sensorValue > 255) { //valeur peut être ajustée, 255 très sensible      
 sensorValue = analogRead(1); //lit la valeur du capteur à nouveau pour la boucle

 servo1.write(possition2);
 current = possition2;
 servo1.write(possition1);
 current = possition1;
 servo2.write(possition2);
 current = possition2;
 servo2.write(possition1);
 current = possition1;
}
 }
  }
   }
    }
}

Merci a tous
Cordialement Dylan.

#73 seb03000

seb03000

    @pump_upp - best crypto pumps on telegram !

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

Posté 06 juin 2012 - 11:34

Difficile a dire pour nous , si le code fonctionne.

De ton coté il aurai fallu toute tes pièces et nous dire si cela fonctionne.

#74 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 07 juin 2012 - 05:35

Oui c'est vrai. Bah vous savez quoi ? cette semaine ou la prochaine je commande mes composants ;)
Merci a tous
Cordialement Dylan.

#75 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 06 décembre 2012 - 07:52

Sakut a tous ! je reprends mon projet !

seul soucis , c'est un probleme de code en Processing 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 ?

Je vous joint ici le code processing avec tout ce qu'il faut sur ce lien : https://www.dropbox....poo5/N6ugzWk-Z8

le code arduino est celui ci en passant :
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); 
}

Merci d'avance de votre aide et bonne soiree a tous
Merci a tous
Cordialement Dylan.

#76 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 08 décembre 2012 - 08:06

Cela fait depuis une semaine que je teste ce code et que j'essaye de trouver l'erreur , mais rien a faire. Quelqu'un peut m'eclaircir ?
Merci a tous
Cordialement Dylan.

#77 Melmet

Melmet

    Pilier du forum

  • Modérateur
  • PipPipPipPipPip
  • 1 521 messages
  • Gender:Male
  • Location:Saint-Sozy (46200)

Posté 08 décembre 2012 - 09:31

Peut tu nous montrer ton code complet?
J'ai l’impression qu'il manque un truc, mais je met pas le doigt dessus!

Ne demande jamais à un robot de faire ce que tu peux faire toi même. :nono: :laugh1:


#78 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 09 décembre 2012 - 10:40

Ceci est un lien avec le dossier complet pour ce qui est de Processing avec les images et le code (qui se trouve tout en bas de la page ,regarder l'image joint pour mieux comprendre)

et le code arduino que voici :
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); 
}

Fichier(s) joint(s)


Merci a tous
Cordialement Dylan.

#79 dydyouaki

dydyouaki

    Membre chevronné

  • Membres
  • PipPipPipPip
  • 792 messages
  • Gender:Male

Posté 13 décembre 2012 - 05:20

quelqu'un s'il vous plait ?
Merci a tous
Cordialement Dylan.

#80 Melmet

Melmet

    Pilier du forum

  • Modérateur
  • PipPipPipPipPip
  • 1 521 messages
  • Gender:Male
  • Location:Saint-Sozy (46200)

Posté 13 décembre 2012 - 06:19

Oui ? :tatice_03:

Ne demande jamais à un robot de faire ce que tu peux faire toi même. :nono: :laugh1:





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

0 members, 0 guests, 0 anonymous users