Arduino uno R3 + motor shield R3 + stepper motor: pins for Stepper constructor

Hi all, please, I need your help.

I use the arduino uno R3 + motor shield R3 and this stepper motor : 17HS Stepper Motor 42mm 1.8degree, MotionKing Stepper Motor

I've connected my unipolar motor with just 4 wires to convert it on a bipolar stepper motor like this:

A+: Green
A-: Black
B+: Red
B-: Blue

I want to use example included in the Arduino (File -> Examples -> Stepper -> stepper_oneRevolution).

Questions are:

  • Wires motor connection on Motor Shield R3 are OK?
  • Which parameters are good for Stepper constructor in the example? I've search a lot on the internet, source code of Stepper but impossible to understand which pins must be affected (Stepper myStepper(200, p1,p2,p3,p4):wink:

Thanks a lot

Hi, I found this on the forum and it works. You can play around with the number of steps and the revs.
hope it helps :slight_smile:

// Include the Stepper Library
#include <Stepper.h>

// Map our pins to constants to make things easier to keep track of
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;

// The amount of steps for a full revolution of your motor.
// 360 / stepAngle
const int STEPS = 480;

// Initialize the Stepper class
Stepper myStepper(STEPS, dirA, dirB);

void setup() {
// Set the RPM of the motor

// Turn on pulse width modulation
pinMode(pwmA, OUTPUT);
digitalWrite(pwmA, HIGH);
pinMode(pwmB, OUTPUT);
digitalWrite(pwmB, HIGH);

// Turn off the brakes
pinMode(brakeA, OUTPUT);
digitalWrite(brakeA, LOW);
pinMode(brakeB, OUTPUT);
digitalWrite(brakeB, LOW);

// Log some shit

void loop() {
// Move the motor X amount of steps
// Pause

// Move the motor X amount of steps the other way
// Pause

Hello recklessrog!
It's exactly the code that I use and it works fine, but... I don't understand the utility of the constructor with five parameters.

If anyone can explain me... :slight_smile: