Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----( Import needed libraries )-----*/
- #include <Stepper.h>
- /*-----( Declare Constants, Pin Numbers )-----*/
- //---( Number of steps per revolution of INTERNAL motor in 4-step mode )---
- #define STEPS_PER_MOTOR_REVOLUTION 32
- //---( Steps per OUTPUT SHAFT of gear reduction )---
- #define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048
- //The pin connections need to be 4 pins connected
- // to Motor Driver In1, In2, In3, In4 and then the pins entered
- // here in the sequence 1-3-2-4 for proper sequencing
- Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 8, 10, 9, 11);
- /*-----( Declare Variables )-----*/
- int Steps2Take;
- void setup() /*----( SETUP: RUNS ONCE )----*/
- {
- // Nothing (Stepper Library sets pins as outputs)
- }
- void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
- {
- Steps2Take = STEPS_PER_OUTPUT_REVOLUTION / 4 ; // Rotate CW 1 turn
- small_stepper.setSpeed(700);
- small_stepper.step(Steps2Take);
- delay(0);
- Steps2Take = - STEPS_PER_OUTPUT_REVOLUTION / 4; // Rotate CCW 1 turn
- small_stepper.setSpeed(700); // 700 a good max speed??
- small_stepper.step(Steps2Take);
- delay(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement