Which Reply# did you get the code from at the other post ?
There are several code examples posted and none of them match yours exactly . Did you change the code you got from the other post ? If not , which Reply# did you get the code from ?
This is your code:
#include <Stepper.h>
const int stepsPerRevolution = 100; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 4,7,8,9);
// give the motor control pins names:
const int pwmA = 7;
const int pwmB = 8;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 8;
const int dirB = 9;
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);
pinMode(brakeB, 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(200);
}
void loop() {
myStepper.step(48);
myStepper.step(-48);
delay(40);
}
This is a code example from the other post:
#include <Stepper.h>
const int stepsPerRevolution = 48; // 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);
// 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);
pinMode(brakeB, 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(2);
}
void loop() {
myStepper.step(48);
myStepper.step(-48);
delay(2000);
}
Do you see the differences ?
YOURS
Stepper myStepper(stepsPerRevolution, 4,7,8,9);
// give the motor control pins names:
const int pwmA = 7;
const int pwmB = 8;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 8;
const int dirB = 9;
CODE FROM OTHER POST
// initialize the stepper library on the motor shield
Stepper myStepper(stepsPerRevolution, 12,13);
// 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;
MOTOR SPECS
Specifications
Current Rating 2.8 A (YOUR POWER SUPPLY: 1 Amp)
Frame Size 56.4 x 56.4mm
Holding Torque 1.26Nm
Number Of Wires 4
Resistance Per Phase 0.9?
Shaft Diameter 6.35mm
Shaft Length 19mm
Step Angle 0.9°
Stepper Motor Type Hybrid, Permanent Magnet
Voltage Rating 2.5 V
What's wrong with this picture ?