Étape 3: Télécharger le croquis
Le flasque arrière du adafruit dispose d’une bibliothèque appelée AFmotor , qui est une bibliothèque de haut niveau en cours d’exécution le flasque arrière du moteur, nous allons utiliser cette bibliothèque.
Voici le code copié à partir de l’exemple de moteur pas à pas qui est inclus dans la bibliothèque de moteur AF.
#include <AFMotor.h> // Adafruit Motor shield library // copyright Adafruit Industries LLC, 2009 // this code is public domain, enjoy! // Connect a stepper motor with 48 steps per revolution (7.5 degree) // to motor port #2 (M3 and M4) AF_Stepper motor(50, 2); void <strong>setup</strong>() { <strong>Serial</strong>.begin(9600); // set up Serial library at 9600 bps <strong>Serial</strong>.println("Stepper test!"); motor.setSpeed(30); // 10 rpm } void <strong>loop</strong>() { <strong>Serial</strong>.println("Single coil steps"); motor.step(50, FORWARD, SINGLE); motor.step(50, BACKWARD, SINGLE); }