#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 12,13);
// Stepper myStepper(stepsPerRevolution * 8, 12,13); partie plus fluide
// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
int x = 0;
void setup() {
Serial.begin(9600);
// set the PWM and brake pins so that the direction pins // can be used to control the motor:
pinMode(pwmA, OUTPUT);
pinMode(pwmB, OUTPUT);
pinMode(brakeA, OUTPUT);
digitalWrite(pwmA, HIGH);
digitalWrite(pwmB, HIGH);
digitalWrite(brakeA, LOW);
digitalWrite(brakeB, LOW);
// initialize the serial port:
Serial.begin(9600);
// set the motor speed (for multiple steps only):
myStepper.setSpeed(10);
}
void loop() {
myStepper.step(210);
delay(3000);
myStepper.step(-210);
delay(3000);
}
And this is my non working code with AFMotor library
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!
#include <AFMotor.h>
// Connect a stepper motor with 48 steps per revolution (7.5 degree)
// to motor port #2 (M3 and M4)
AF_Stepper motor(200, 1);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");
motor.setSpeed(5); // 10 rpm
}
void loop() {
Serial.println("Single coil steps");
motor.step(200, FORWARD, SINGLE);
motor.step(200, BACKWARD, SINGLE);
Serial.println("Double coil steps");
motor.step(200, FORWARD, DOUBLE);
motor.step(200, BACKWARD, DOUBLE);
Serial.println("Interleave coil steps");
motor.step(200, FORWARD, INTERLEAVE);
motor.step(200, BACKWARD, INTERLEAVE);
Serial.println("Micrsostep steps");
motor.step(200, FORWARD, MICROSTEP);
motor.step(200, BACKWARD, MICROSTEP);
}