Modifications

Sauter à la navigation Sauter à la recherche
Ligne 33 : Ligne 33 :  
== Ecrire du code pour plusieurs shields ==
 
== Ecrire du code pour plusieurs shields ==
   −
The Adafruit_MotorShield library has the ability to control multiple shields, unlike the older AF_Motor library. First we must create a Motor Shield Controller for each shield, with the assigned address.
+
La bibliothèque Adafruit_MotorShield est capable de contrôler plusieurs shield (ce qui radicalement différent de l'ancienne bibliothèque AF_Motor).  
   −
<nowiki>Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closed
+
=== Créer les MotorShield ===
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers</nowiki>
+
Nous devons d'abord créer un contrôleur pour chaque motor shield, en indiquant l'adresse assignée sur chaque carte.
   −
One motor shield is going to be called AFMSbot (bottom shield, so we remember) and one is AFMStop (top shield) so we can keep them apart. When you create the shield object, specify the address you set for it above.
+
Lorsque vous créez les objets shield, n'oubliez pas de spécifier l'adresse comme nous le faisons ci-dessous:
   −
Then we can request the motors connected to each one
+
<nowiki>Adafruit_MotorShield AFMSbot(0x61); // Le cavalier/pastille le plus à gauche ponté
 +
Adafruit_MotorShield AFMStop(0x60); // Adresse par défaut, sans pontage</nowiki>
   −
  <nowiki>// On the top shield, connect two steppers, each with 200 steps
+
* Un des shield moteur est nommé AFMSbot (Shield du bas, pour mémoire. "''bot''" signifie "robot")
 +
* L'autre shield est nommé AFMStop (le shield du haut, "''top''" signifiant "haut").
 +
 
 +
Voila, nous pouvons maintenant identifier distinctement les deux shields.
 +
 
 +
=== Associer les moteurs ===
 +
 
 +
Nous pouvons ensuite demander les différents objets pour chacun des moteurs raccordés sur les shields.
 +
 
 +
  <nowiki>// Sur le shield du dessus (top), connectez 2 mot. pas-à-pas, chacun de 200 pas
 
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 1);
 
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 1);
 
Adafruit_StepperMotor *myStepper3 = AFMStop.getStepper(200, 2);
 
Adafruit_StepperMotor *myStepper3 = AFMStop.getStepper(200, 2);
   −
// On the bottom shield connect a stepper to port M3/M4 with 200 steps
+
// Sur le shield du bas (bot), connecter un mot. pas-à-pas de 200 pas sur le bornier M3/M4.
 
Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(200, 2);
 
Adafruit_StepperMotor *myStepper1 = AFMSbot.getStepper(200, 2);
// And a DC Motor to port M1
+
// et un moteur continu sur le bornier M1
 
Adafruit_DCMotor *myMotor1 = AFMSbot.getMotor(1);</nowiki>
 
Adafruit_DCMotor *myMotor1 = AFMSbot.getMotor(1);</nowiki>
   −
You can request a stepper or DC motor from any port, just be sure to use the right AFMS controller object when you call '''getMotor''' or '''getStepper'''!
      +
Vous pouvez réclamer n'importe quel objet ''stepper'' ou ''motor' sur n'importe quel port, veillez juste à utiliser le bon "objet controleur AFMS" lorsque vous appelez '''getMotor''' ou '''getStepper'''!
 +
 +
=== Initialiser ===
 
Then, both shields must have '''begin''' called, before you use the motors connected
 
Then, both shields must have '''begin''' called, before you use the motors connected
 
  <nowiki>AFMSbot.begin(); // Start the bottom shield
 
  <nowiki>AFMSbot.begin(); // Start the bottom shield
29 917

modifications

Menu de navigation