My stepper motor turn just in one direction

Hi, I have a problem with my stepper motor 17HS4401, I connected it with DVR8825( driver)

I set vref to 1.2v and i upload this code

/* stepper motor control code for DRV8825
 * 
 */

 // define pin used
 const int stepPin = 9;
 const int dirPin = 8;
 
 void setup() {
 // set the two pins as outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

}

void loop() {
digitalWrite(dirPin,HIGH); //Enables the motor to move in a perticular direction
// for one full rotation required 200 pulses
for(int x = 0; x < 200; x++){
  digitalWrite(stepPin,HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin,LOW);
  delayMicroseconds(500);
}
delay(1000); // delay for one second


digitalWrite(dirPin,HIGH); //Enables the motor to move in a opposite direction
// for three full rotation required 600 pulses
for(int x = 0; x < 600; x++){
  digitalWrite(stepPin,HIGH);
  delayMicroseconds(500);
  digitalWrite(stepPin,LOW);
  delayMicroseconds(500);
}
delay(1000); // delay for one second
}

The motor should turn in the two directions, but it turns just in one direction.

Hi,
You are setting the direction pin HIGH in both cases... One case needs to be LOW I think..

Thanks the motor works fine, but I have 2 more questions please :
1- When the motor stops turning i hear a whistle, is there any method to reduce this sound?
2- Can the wires in the motor connector drive 2 amps? because i think they are very weak.

If the wires came with the motor I would expect them to be OK. You don't need much copper to carry 2 amps unless the distance is very long.

2 amps is probably a bit too much for a DRV8825 unless you have a heat sink and an cooling fan. It is not a good idea to operate electronic equipment close to the limit of its capacity.

Post a link to the datasheet for your motor.

...R

Robin2:
If the wires came with the motor I would expect them to be OK. You don’t need much copper to carry 2 amps unless the distance is very long.

2 amps is probably a bit too much for a DRV8825 unless you have a heat sink and an cooling fan. It is not a good idea to operate electronic equipment close to the limit of its capacity.

Post a link to the datasheet for your motor.

…R

I followed the same instructions this website Pololu - DRV8825 Stepper Motor Driver Carrier, High Current.
My motor (17HS4401) have 1.7A as rated current and I use full step setting so the measured current will be 0.7 times (70%) the current limit :

current limit = 1.7A / 0.7 = 2.43A
Vref = current limite / 2 ==> 2.43/2 2.43 = 1.21V
what do you think ?

I reckon the DRV8825 should be OK with a 1.7 amp motor.

...R