Adafruit Motor Shield V2-Logiciel
Installer la bibliothèque
Vous devez installer la bibliothèque/librairie Adafruit Motorshield v2 pour utiliser ce shield sur un Arduino. Cette bibliothèque n'est pas compatible avec l'ancienne librairie AF_Motor utilisé avec les shield de v1.
Si vous avez du code pour l'ancienne librairie, le code ne sera pas difficile à adapter pour ce nouveau shield. L'interface de librairie à été légèrement modifiée pour supporter l'empilement de shield, ce qui en vaut largement le coup!
- Commencez par télécharger l'archive zip de la librairie/bibliothèque depuis le dépôt Github d'Adafruit. Vous pouvez également cliquer sur ce lien pour télécharger la dernière librairie Adafruit Motor Shield V2.
- Copiez le répertoire (disponible à l'intérieur de l'archive zip) dans le répertoire Libraries accessible à l'intérieur du répertoire "Sketchbook" de votre installation Arduino.
- N'oubliez pas de renommez le répertoire de la librairie Adafruit_Motorshield
- Pour finir, redémarrez Arduino IDE pour charger la librairie et ses exemples.
Vous pouvez consulter notre tutoriel dédicacé à l'installation de librairie Arduino!
Exécuter les exemples
Moteur continu
La librairie dispose de quelques exemples vous permettant de commencer rapidement vos expérimentations. Nous proposons de commencer par l'exemple dédicacé au moteur continu. Vous pouvez utiliser n'importe quel moteur DC qui peut être alimenté entre 6V-12V DC
Plug the shield into the Arduino and connect a DC motor to motor port 1 - it does not matter which wire goes into which terminal block as motors are bi-directional. Connect to the top two terminal ports, do not connect to the middle pin (GND) See the photo below for the red and blue wire example. Be sure to screw down the terminal blocks to make a good connection!
You must also supply 5-12VDC to power the motor. There are two ways to do this
- You can power the Arduino via the DC Barrel Jack and insert the VIN Jumper shown as the tall black handle right next to the green Power LED below
- You can power the Arduino via the DC Barrel jack or USB port. Then Power the shield via the 5-12VDC motor power terminal port, the double terminal block next to the green Power LED and remove the VIN jumper
If the Green LED isn't lit up brightless do not continue - you must power it via the VIN jumper or the terminal block
Once you have verified the motor is connected properly and you have the power LED lit up brightly, we can upload our code.
In the IDE, load File->Examples->Adafruit_MotorShield->DCMotorTest
You should see and hear the DC motor turn on and move back and forth, attaching a slip of paper or tape as a 'flag' can help you visualize the movement if you have trouble seeing the movement
Test de moteur pas-à-pas
You can also test a stepper motor connection with the shield. The shield can run unipolar (5-wire and 6-wire) and bipolar (4-wire) steppers. It cannot run steppers with any other # of wires! The code is the same for unipolar or bipolar motors, the wiring is just slightly different.
Plug the shield into the Arduino and connect a stepper motor to motor port 2 - unlike DC motors, the wire order does 'matter'. Connect to the top two terminal ports (coil #1) and the bottom two terminal ports (coil #2).
- If you have a bipolar motor, do not connect to the middle pin (GND).
- If you are using a unipolar motor with 5 wires, connect the common wire to GND.
- If you are using a unipolar motor with 6 wires, you can connect the two 'center coil wires' together to GND
You must also supply 5-12VDC to power the motor. There are two ways to do this
- You can power the Arduino via the DC Barrel Jack and insert the VIN Jumper shown as the tall black handle right next to the green Power LED below
- You can power the Arduino via the DC Barrel jack or USB port. Then Power the shield via the 5-12VDC motor power terminal port, the double terminal block next to the green Power LED and remove the VIN jumper
If the Green LED isn't lit up brightless do not continue - you must power it via the VIN jumper or the terminal block
Once you have verified the motor is connected properly and you have the power LED lit up brightly, we can upload our code.
In the IDE, load File->Examples->Adafruit_MotorShield->StepperTest
You should see and hear the stepper motor turn on and move back and forth, attaching a slip of paper or tape as a 'flag' can help you visualize the movement if you have trouble seeing the movement. There are four ways to move a stepper, with varying speed, torque and smoothness tradeoffs. This example code will demonstrate all four.
Source: Adafruit Motor Shield V2 for Arduino créé par LadyAda pour AdaFruit Industries. Crédit [www.adafruit.com AdaFruit Industries]
Traduit par Meurisse D. pour MCHobby.be
Nos remerciements à Mr Pierre M. pour ses suggestions de correction.
Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.