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.
Video demo
Arduino code for CD-ROM Stepper
#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);
}
Helped a lot , thanks.
Hello
Can show me in a graphic how can I connect the stepper motor to driver shield?
Thanks
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
tanks friend,
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!
thank you bro,
i have made it, its very helpful and very easy video
Why there is so lot of spam on your website?!
Where is exit?!
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.
Help me, I use a mega arduino and is giving error when compiling the code and a message appears with the final / 223,
Arduino: 1.8.0 (Windows 7), Board: “Arduino/Genuino Uno”
C:\Users\The Ocean Mall\Downloads\CNC_code\CNC_code.ino:3: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.
You can download AFmotor library.
Please help me
Arduino: 1.8.0 (Windows 7), Board: “Arduino/Genuino Uno”
C:\Users\The Ocean Mall\Downloads\CNC_code\CNC_code.ino:3: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.
This is not CD-ROM stepper, but this is DVD-ROM stepper, it’s different!
help me how to solve the problem when uploading shows below dialog box,
compilation terminated.
Exit status 1
Error compiling for board arduino / genuine uno.
You download AFmotor.h library.
hello
ı take stray 342 error pls help me anyone else my email cankawas_bjk@hotmail.com
can you send me ino documents pls help me
stepper_test:8: error: stray ‘\’ in program
stepper_test:8: error: stray ‘\’ in program
stepper_test:13: error: stray ‘\’ in program
stepper_test:13: error: stray ‘\’ in program
stepper_test:4: error: ‘AF_Stepper’ does not name a type
stepper_test.ino: In function ‘void setup()’:
stepper_test:8: error: ‘u201cStepper’ was not declared in this scope
stepper_test:9: error: ‘motor’ was not declared in this scope
stepper_test:9: error: expected `)’ before numeric constant
stepper_test.ino: In function ‘void loop()’:
stepper_test:13: error: ‘u201cMicrsostep’ was not declared in this scope
stepper_test:14: error: ‘motor’ was not declared in this scope
stepper_test:14: error: ‘FORWARD’ was not declared in this scope
stepper_test:14: error: ‘MICROSTEP’ was not declared in this scope
stepper_test:15: error: ‘BACKWARD’ was not declared in this scope
plzz help me
Hello i am new user and i would to ask you, How to disable avatar?