je suis à la recherche d'une initiation de code pour 4 motor shield, en fait j'ai reussi à faire fonctionner 2 moteurs avec un shield avec ce code:
#include <Servo.h>
const int
PWM_A1 = 3,
DIR_A1 = 12,
BRAKE_A1 = 9,
SNS_A1 = A0,
PWM_B1 = 11,
DIR_B1 = 13,
BRAKE_B1 = 8,
SNS_B1 = A1;
void setup() {
pinMode(BRAKE_A, OUTPUT); // Brake pin on channel A
pinMode(DIR_A, OUTPUT); // Direction pin on channel A
pinMode(BRAKE_A, OUTPUT); // Brake pin on channel A
pinMode(DIR_A, OUTPUT); // Direction pin on channel A
pinMode(BRAKE_B, OUTPUT); // Brake pin on channel B
pinMode(DIR_B, OUTPUT); // Direction pin on channel B
pinMode(BRAKE_B, OUTPUT); // Brake pin on channel B
pinMode(DIR_B, OUTPUT); // Direction pin on channel B
// Open Serial communication
Serial.begin(9600);
Serial.println("Motor shield DC motor Test:\n");
}
void loop() {
digitalWrite(BRAKE_A, LOW); // setting brake LOW disable motor brake
digitalWrite(DIR_A, HIGH); // setting direction to HIGH the motor will spin forward
analogWrite(PWM_A, 255); // Set the speed of the motor, 255 is the maximum value
digitalWrite(BRAKE_B, LOW); // setting brake LOW disable motor brake
digitalWrite(DIR_B, HIGH); // setting direction to HIGH the motor will spin forward
analogWrite(PWM_B, 255);
Bah c'est la meme chose, tant que tu declare les broches aux bons endroit (impossible avec des shields officiels cependant puisque les broches des deux shields serait en collision)
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
Retrouvez moi sur mon blog et ma chaine Youtube !