1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <Stepper.h>
// Defines pins numbers
const int stepPin = 3;
const int dirPin = 4;
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
Stepper myStepper(stepsPerRevolution, 2,3);
int stepCount = 0; // number of steps the motor has taken
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
digitalWrite(dirPin,HIGH); //Enables the motor to move in a particular direction
}
void loop() {
myStepper.setSpeed(5); //this is the RMP, meaning 1000 steps per minute I believe...
myStepper.step( (5*200)/360 ); //this should move it around 2.7 steps at a time
} |
Partager