stepper motor turns 1 way only

hi, i connected a nema 17 motor to drv8825 by this diagram:
and wrote this code:

#include <Stepper.h>
const int stepsPerRevolution = 1600;
const int directionPin=3;
const int stepPin=5;
Stepper myStepper(stepsPerRevolution,stepPin,directionPin);
int dir=0;
void setup() {


void loop() 

when dir=0 - everything is ok, but if dir=1 - the motor hold its place.
i searched the web for solutions, and tried everything i’ve found, nothing worked.
i hope that there is someone here that could help me.

That is an awfully low-resolution picture. I hope you were working from something better.

First check your wiring. It's possible you've connected to an "enable" pin instead of the direction pin. Then check it again against other references for the same hardware.

The standard Stepper library is not intended for use with a stepper driver that takes step and direction signals.

Have a look at this Simple Stepper Code which does not need any library. Also look up the AccelStepper library.

Stepper Motor Basics

Your sketch never sets 'dir' to anything but 0.