Drive CD-ROM Stepper Motor with Arduino + L293d shield

Here is I am shearing the code for drive a CD-Rom Stepper Motor. You can also watch the demo video.

To drive stepper motor I am using…

  • Arduino UNO
  • Adafruit driver shield (L293d driver shield)
  • CD Rom stepper motor

You have to connect the stepper motor to driver shield.

Subscribe to our channel to get cool projects!

 

Here is the arduino code.

#include <AFMotor.h>
// Motor with 200 steps per rev (1.8 degree)
// to motor port #1 (M1 and M2)
AF_Stepper motor(200, 2);
void setup() {
// set up Serial library at 9600 bps
Serial.begin(9600);
Serial.println(“Stepper test!”);
motor.setSpeed(4 00); // 50 rpm
}
void loop() {

Serial.println(“Micrsostep steps”);
motor.step(50, FORWARD, MICROSTEP);
motor.step(50, BACKWARD, MICROSTEP);
motor.step(100, FORWARD, MICROSTEP);
motor.step(100, BACKWARD, MICROSTEP);
motor.step(200, FORWARD, MICROSTEP);
motor.step(200, BACKWARD, MICROSTEP);
motor.step(250, FORWARD, MICROSTEP);
motor.step(250, BACKWARD, MICROSTEP);
delay(100);

motor.step(3, FORWARD, MICROSTEP);
motor.step(3, BACKWARD, MICROSTEP);
delay(1000);
}

Related Post

7 Comments
  1. Rhayan 3 years ago

    Helped a lot , thanks.

  2. CoolDann 2 years ago

    Hello
    Can show me in a graphic how can I connect the stepper motor to driver shield?

    Thanks

  3. xuân hồi 2 years ago

    hello D project I need to use one motor step
    cycle works as follows. Press 1 stepper motor is run with 180-degree rotation and stop at that. While pressing 2 rotary step motor with reverse rotation as well with 180 degree rotation and stop there
    I use Arduino & L298N
    thank D

  4. hugo cruz 2 years ago

    tanks friend,

  5. Omar 2 years ago

    Thank you for the code and sharing, i learned a lot whit it, just to let you know (im a newbie) i had an error in the code (my bad) in this line:
    motor.setSpeed(4 00); // 50 rpm

    because of the space between the 4 and 00 😉

    Thank you!

  6. anil 5 months ago

    Where do i get the #include file “AFMotor.h”?
    My compiler is giving file not found error when i click upload

    error:
    Arduino: 1.8.0 (Windows 7), Board: “Arduino/Genuino Uno”

    C:\Users\harish\Documents\Arduino\sketch_jan20c\sketch_jan20c.ino:1:21: fatal error: AFMotor.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

  7. Rodrigo Jhordam Freire Neves 5 months ago

    Help me, I use a mega arduino and is giving error when compiling the code and a message appears with the final / 223,

Leave a reply

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

*

or

Log in with your credentials

or    

Forgot your details?

or

Create Account