Bonjour,
J’ai fais un programme pour faire fonctionner un moteur pas a pas dans les deux sens mais il ne fonctionne pas.
Quelqu’un pourrait-il m’aider?
// defines pins numbers
const int stepPin = 13;
const int dirPin = 12;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
long unsigned Time;
Serial.print("Temps: ");
Time = millis();
Serial.println (Time);
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++) {
digitalWrite(stepPin,HIGH);
delay(10);
digitalWrite(stepPin,LOW);
delay(10);
}
delay(1000); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 400; x++) {
digitalWrite(stepPin,HIGH);
delay(10);
digitalWrite(stepPin,LOW);
delay(10);
}
delay(1000);
}
Merci d’avance.