Hello everyone!
I am having some trouble controlling the stepper motor. For the setup I'm using the DRV8825. In the attachment you can see how I wired it.
I wired from above; orange, blue, red and yellow (see other attachment). When I used a code to drive this it wouldn't make circles. Instead it was making noises and holding its position.
Does anyone know what the problem is? It would make my day!
This was the code I was using:
// --- Commande d'un StepStick/Driver A4988 ----------------------
// DRV8825_Test.ino
//
// Commande d'un moteur pas-à-pas à l'aide d'un pilote DRV8825 avec
// Arduino.
//
// Un projet www.mchobby.be (vente de kit et composant)
// Meurisse D. - Licence CC-SA-BY
//
// Un tutoriel DRV8825 — MCHobby - Wiki
// Ou Acheter un StepStick DRV8825
// DRV8825 - Controleur moteur pas-à-pas
//
#define pinEnable 13 // Activation du driver/pilote
#define pinStep 9 // Signal de PAS (avancement)
#define pinDir 8 // Direction
void setup(){
Serial.begin(9600);
Serial.println("Test DRV8825");
pinMode( pinEnable, OUTPUT );
pinMode( pinDir , OUTPUT );
pinMode( pinStep , OUTPUT );
}
void loop(){
int i = 0;
digitalWrite( pinDir , HIGH); // Direction avant
digitalWrite( pinStep , LOW); // Initialisation de la broche step
// Avance de 200 pas
for( i=0; i<200; i++){
Serial.println( i );
digitalWrite( pinStep, HIGH );
delay( 10 );
digitalWrite( pinStep, LOW );
delay( 10 );
}
// Changer de direction
digitalWrite( pinDir , LOW); // Direction avant
// Refaire 200 pas dans l'autre sens
for( i=0; i<200; i++){
Serial.println( i );
digitalWrite( pinStep, HIGH );
delay( 1 );
digitalWrite( pinStep, LOW );
delay( 1 );
}
// Pas de step et pas d'ordre...
// l'axe du moteur est donc bloqué
Serial.println("Axe bloqué + attendre 5 sec");
delay( 5000 );
// déblocage de l'axe moteur
Serial.println("Deblocage axe");
digitalWrite( pinEnable, HIGH ); // logique inversée
// Fin et blocage du programme
// Presser reset pour recommander
Serial.println("Fin de programme");
while( true );
}
![640px-DRV8825-Montage_Rouge-Bleu-Vert-Noir.jpg](https://europe1.discourse-cdn.com/arduino/original/4X/3/f/b/3fb2c55f08bae45c4909ba9fec9ff0715c3738b7.jpeg)
![kleuren.png](https://europe1.discourse-cdn.com/arduino/original/4X/e/2/9/e29ad4c4f9098ab656a9680af7f8b1929170b380.png)