Camera slider with stepper motor.

Hi there! I am trying to build timelapse slider for camera based on arduino controlled stepper motor. Project video url:

wire diagram


I am using arduino nano v3 (328), keypad lcd shield and Easydriver for stepper motor Stepper motor is from old printer and manufacturer didn’t publish datasheet for it. It is bipolar,4 wire, 200 steps per revolution (17PM type) and I can’t get other specs. So far, my keyboard and display working. When it is powered (driver with 12v, arduino and display with 5v through LM7805) it is blocked and unresponsive. I didn’t change script except parameters for my hardware

#define STEPS_PER_MM 250 // number of steps per mm movement
#define STROKE_MM 950 // full stroke of slider in mm

I tried this wiring and code and stepping is working.

I am not electronics. Any help appreciated. Thanks.

You said "wiring and code and stepping is working." so what's the problem?

And it's much easier if you post your code in the forum using the code tags. If the code is very long it would help if you could produce a complete short sketch that just deals with the problem.


Hi. I din’t explain problem well. This is code bildr Use The EasyDriver Stepper Motor Driver + Arduino - bildr that I was trying just for test conection and it is working.

This is part of the code for slider which I am trying to make it work. This part is driving motor.

motor_pulse_steps_dolly(void) // PATCH this should be via interrupt to keep going
long nStep;
long nDelay;
long nStepPerSec;
nStepPerSec = (long) nStroke * STEPS_PER_MM / 60 / nSpeedMinutes;
nStep = nStepPerSec / ( 1000 / nCycleTimeMS);
nDelay = 1000 / nStep * nCycleTimeMS;
motor_pulse_steps(nStep, nDelay, bStepDirUP);
motor_pulse_steps(long nStep, long nDelay, boolean bDir)
int i;
digitalWrite(IO_STEP_ENABLE, LOW); // Enable the stepper motor
digitalWrite(IO_STEP_DIR, (bDir) ? HIGH: LOW); // set direction
for (i = 0; i < nStep; i++)
digitalWrite(IO_STEP_STEP, HIGH);
digitalWrite(IO_STEP_STEP, LOW);
nPositionStep += (bDir) ? + nStep: - nStep;
nPositionMM = nPositionStep / STEPS_PER_MM;
motor_pulse_steps_linear(unsigned long steps)
// moving individual motors with a linear speed ramp
// this speed ramp is used only to optimize torque,
// minimize motor noise, missed steps, and prevent
// excessive motion causes by a motor started and
// stopped at full-speed.
if (steps == 0)
digitalWrite(IO_STEP_ENABLE, LOW); // Enable the stepper motor
digitalWrite(IO_STEP_DIR, (bStepDirUP) ? HIGH: LOW); // set direction
// shelf where motor speed ramp starts and stops
unsigned long shelf_lo = steps / 3;
unsigned long shelf_hi = shelf_lo * 2;
// we can't have our ramp rate be zero, which it would be
// if shelf_lo were >= the difference between min and max
// ramp rate. This happens when large moves (thousand+ steps)
// try to use 1/3rd shelf up and down. So, reduce shelf
// by ten percent until we get a reasonable range...
while( shelf_lo >= ( motor_max_step - motor_min_step ) ) {
shelf_lo = shelf_lo - ( (unsigned long) ( (float) shelf_lo * (float) 0.1 ) );
shelf_hi = steps - shelf_lo;
unsigned int delay_increment = ( motor_max_step - motor_min_step ) / shelf_lo;
unsigned int delay = 0;
for( long i = 0; i < steps ; i++ ) {
digitalWrite(IO_STEP_STEP, HIGH);
if( i < shelf_lo ) {
// we're ramping up to speed
delay = ( delay_increment * ( shelf_lo - i ) ) + motor_min_step;
else if( i > shelf_hi ) {
// we're ramping down from speed
delay = ( delay_increment * ( i - shelf_hi ) ) + motor_min_step;
else {
// wer're moving at maximum speed
delay = motor_min_step;
digitalWrite(IO_STEP_STEP, LOW);
} // end for loop

I tryed change this (more and less) but it din’t help.

// minimum uSeconds between motor steps
unsigned int motor_min_step = 500; // fastest stepping speed
unsigned int motor_max_step = 1000;

nCycleTimeMS is set to 50.
Whole code is on Arduino Slider Control · GitHub

Problem is that motor is humming but not moving.
What I should change? Where to start?

Sorry, but I'm too lazy to try to learn how all that complex code works. Can you describe what it's supposed to do?

You said that you have code that does work?

How does that differ (and why) from the code that doesn't work?

Can you not use the working code and incrementally amend it to add features (if that's what you need?) getting it working at each stage before moving on to the next stage. That's how I would do it.

If you need acceleration in your code have you looked at the AccelStepper library?


Try adjusting the little pot on the Easydriver I have found that can cause humming if not properly set