Battery drain l293d and stepper motor

Hi,
I got the arduino uno and a bipolar stepper to work with a l293d h bridge using the code posted on arduino website.

However have a problem. For my application, I inserted a delay of 2 days between each forward step. However doing so caused the 9v battery connected to l293d and stepper to drain fairly quicky. Is there a way to avoid power drain during the 2 days?

Basically the code is:

Serial.println("Forward");
myStepper.step(motorSteps);

// Delay for 2 days using delay (1000) in a loop
delayforNday(2);

// Step forward
Serial.println("Forward");
myStepper.step(motorSteps);

Thanks.

When the motor finishes its stepping one coil remains energised locking the spindle in place. This will drain a little 9V battery in no time at all.

You need to cut all power to the motor (by setting the h-bridge in "brake" mode) and, ideally, send the Arduino to sleep for 2 days. To wake it up after such a long period you'd need an external interrupt - say from an RTC chip.

You also need a real battery. Put the 9V battery back in the smoke detector where it belongs.

Hi Majenko,
Nice suggestion.
How do I brake the motor?

Will myStepper.step(0) do the trick after moving it forward?

Thanks.

Will myStepper.step(0) do the trick after moving it forward?

Do what trick?

How is the stepper motor being driven? What hardware do you have between the Arduino and the stepper motor?

Taking 0 steps will not remove all power from the stepper motor.