New Stepper Motor Example code that works
code: [select]
/*
stepper motor control - 1 revolution
program drives unipolar or bipolar stepper motor.
motor attached digital pins 8 - 11 of arduino.
motor should revolve 1 revolution in 1 direction, then
1 revolution in other direction.
created 11 mar. 2007 tom igoe
modified 30 nov. 2009 tom igoe
modified 24 aug. 2016 dave gordon https://www.youtube.com/channel/ucw0rquafdm8u-0hfqnqz8aq
*/
#include <stepper.h>
const int stepsperrevolution = 2048; // change fit number of steps per revolution motor
// initialize stepper library on pins 8 through 11:
stepper mystepper(stepsperrevolution, 8, 10, 9, 11);
void setup() {
// set speed @ 10 rpm: (15 or less motors , controllers)
mystepper.setspeed(10);
// initialize serial port:
serial.begin(9600);
}
void loop() {
// step 1 revolution in 1 direction:
serial.println("clockwise");
mystepper.step(stepsperrevolution);
delay(50);
// step 1 revolution in other direction:
serial.println("counterclockwise");
mystepper.step(-stepsperrevolution);
delay(50);
}
changes: changed stepsperrevolution more in line current stepper motors
changed initiating stepper class - pins changed reflect stepper motor driver pin out documentation
changed stepperspeed 10 motors kits don't work on 15 rpm
changed delay 50. 500ms long.
Arduino Forum > Development > Other Software Development > New Stepper Motor Example code that works
arduino
Comments
Post a Comment