DVD stepper motor + L293D shield

 

Today we will use the L293D shield to reuse a stepper motor from a broken DVD.
Connections:     coil 1 to M3 (motor 3) on the shield and coil 2 to M4
(as shown in the picture), the Battery+ to M+ and Battery- to GND.

Arduino code.

#include <AFMotor.h>
 
 
    AF_Stepper motor(200,2); 
 
 
    void setup() {
      Serial.begin(9600);           
      Serial.println("Stepper test!");
 
      motor.setSpeed(20);  // 20 rpm   
    }
 
    void loop() {
      motor.step(100, FORWARD, INTERLEAVE); 
      delay(500);
      motor.step(100, BACKWARD, INTERLEAVE); 
      delay(500);
 
    }
  1. AF_Stepper(steps, stepper#Steps indicates how many steps per revolution the motor has. a 7.5degree/step motor has 360/1,8 = 200 steps. Stepper# is which port it is connected to. If you’re using M1 and M2, its port 1. If you’re using M3 and M4 it’s port 2
  2. Set the speed of the motor using setSpeed(rpm) where rpm is how many revolutions per minute you want the stepper to turn.
  3. Then every time you want the motor to move, call the step(#steps, direction, steptype) procedure.#steps is how many steps you’d like it to take. direction is either FORWARD or BACKWARD and the step type is SINGLE, DOUBLE, INTERLEAVE or MICROSTEP. 

In my case the motor didn’t spin very well, I played with the values of steps in AF_Stepper()
and SINGLE ΟΡ MICROSTEP didn’t work at all. Also at first I didn’t use the external battery
and I had problems because the usb couldn’t provide enough power. You can find the
AFMotor.h library here.
 

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *