How to turn off motors?


I use 2x NEMA 17 (12V 1,2A) and I use power plug 12V 1,5A. I control them by CNC shield and DRV8266 driver. My code is:

#define EN 8      /* Enable pin for all stepper outputs */

#define X_DIR 5   /* Direction pin for X axis */
#define X_STEP 2  /* Step pin for X axis */

#define Y_DIR 6   /* Direction pin for Y axis */
#define Y_STEP 3  /* Step pin for Y axis */

#define A_DIR 13  /* Direction pin for Aux driver. Requires D13 and A-DIR pins to be shorted */
#define A_STEP 12 /* Direction pin for Aux driver. Requires D12 and A-STEP pins to be shorted */

#define X_ENDSTOP 9   /* X axis endstop input pin */
#define Y_ENDSTOP 10  /* Y axis endstop input pin */
#define Z_ENDSTOP 11  /* Z axis endstop input pin */
#define ABORT A0  /* Abort input pin */
#define HOLD A1   /* Hold input pin */
#define RESUME A2 /* Resume input pin */

boolean Direction = LOW; /* Rotational direction of stepper motors */

void setup() {
/* Initialize serial */

  /* Configure the steper drive pins as outputs */
  pinMode(EN, OUTPUT);
  pinMode(X_DIR, OUTPUT);
  pinMode(X_STEP, OUTPUT);
  pinMode(Y_DIR, OUTPUT);
  pinMode(Y_STEP, OUTPUT);

  /* Configure the control pins as inputs with pullups */


  /* Enable the X, Y, Z & Aux stepper outputs */
  digitalWrite(EN, LOW); //Low to enable

void loop() 


All works good but I would like to turn off motor when it moved but I don't know how.

Thanks for all advice.

Start by having a look at the examples in this Simple Stepper Code. I think they will answer your question.

If not, please explain more clearly what you are having difficulty with.

It would also be useful if you can post a link to the datasheet for the stepper driver board you are using. I have not come across the DRV8266 before and I did not find anything obvious when I searched.

...R Stepper Motor Basics

Ok so CNC shield is here and DRV 8825 driver here Pololu - DRV8825 Stepper Motor Driver Carriers, High Current – I am sorry I wrote post before wrong number of driver it is DRV8825.

I know control motor but my problem is that when I moved on some position, my motor start whistling and motor keep his position. But I don’t need that motor keep his position - I would like to stop this motor - something like turn off from electric but by programming.
I would like to have motor, which after move on some position turn off. If I would like to use it again, motor turn on … etc.

Pull SLEEP pin low to sleep the DRV8825 driver? That ought to do it.

Please, can you write example how to do this? I am newbie in control motors. :(

Ok so I solved problem:

digitalWrite(EN, HIGH);

When I put pin EN to HIGH, motors don't keep their position and when I want to use them I put pin EN to LOW :)