I'm new to Arduino and microcontrollers in general. I've had an Uno for about a half of a year. Using the diagram posted by Tom Igoe (link below), I made an H-bridge to allow me to control a stepper motor with my Arduino. I made the mistake of buying an Arduino's R3 motor shield, not realizing that the design was so new. Come to find out there is little to no documentation to be found on it. My problem is that I have no clue (other than mounting the shield) on how to wire in the stepper motor and what changes to make to the sketch which works with my H-bridge. This my first shield, so I am confused as to which pins are inputs, which are outputs and which are definable. Any help would be appreciated.
At the bottom of the page, you can find a couple of links to additional information including a sample program.
In the sample for V3, I see the pinouts, which are different than the V1 pins of 9 & 10 instead of 10 & 11:
int dirA = 12;
int dirB = 13; // not used in this example
int speedA = 10;
int speedB = 11; // not used in this example
The other pins should be available if you can get to them somehow. I’m not quite sure how to hook up your stepper since I don’t have one here to test with. Maus
Sorry, this motor shield is not intended to drive a stepper motor, it’s only useful for DC motors using one PWM and direction (optional break) pin per motor. For a stepper you would need for individual pins.
Even the page he linked to says different. You will however have to do some homework. Because as he said, you will require four pins to drive a stepper. Look up the datasheet for the 298 and find the pinout. Find out where all for IN x pins go on the board. From there, as long as they are directly connected. You are in business. Otherwise, you will need to question arduino directly on how to drive a stepper with the board.
To be honest, this was an impulse buy. I wanted to get rid of a RS card that’s been in my wallet for some time. I also wanted try out a shield (any shield) for the Arduino. I didn’t read up on it before hand. I’ll take the advice given and do a little more research. Maybe I’ll find a use (if not for robots) so I can justify the purchase.
void loop() { // move the motor A to one direction increasing speed digitalWrite (dirA, HIGH); for (int j = 0; j < 255; j += 10) { analogWrite (speedA, j); delay (100); }
// stop the motor digitalWrite(speedA, LOW);
delay(1000); // keep the motor rolling for one second
// move the motor A to one direction decreasing speed digitalWrite (dirA, LOW); for (int j = 255; j >= 0; j -= 10) { analogWrite (speedA, j); delay (100); }
// stop the motor digitalWrite(speedA, LOW);
delay(1000); // keep the motor stopped for one second