Hello everybody,
I am new to using Arduino and building circuits and I've run into some trouble controlling a stepper motor.
I want to precisely control a NEMA 17 bipolar stepper motor using an L298N Dual H-bridge motor controller connected to an Arduino UNO. I have 12V-2A power source connected to the L298N motor controller, and a 9V battery connected to the UNO. I am also using the Arduino Stepper Motor example, which I have pasted below. I have also included the link to the place I ordered the motor as well.
I have the 8, 9, 10, 11 digital pins connected to IN 1, IN 2, IN 3, and IN 4 on the L298N respectively. I also have the motor A and A\ pins connected to OUT 1 and OUT 2 and B and B\ connected to OUT 3 and OUT 4.
When I use the code that I've provided, despite being the right number of steps per revolution (the motor's step angle is 1.80 degrees), the motor barely moves and does not make a complete rotation. I've been reading through some other threads and looking at guides online but I can't figure out for the life of me what I am doing wrong.
Thank you in advance for your help!
/*
Stepper Motor Control - one revolution
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
*/
#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 pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
// step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);
// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}
Link to the Stepper Motor: STEPPERONLINE Nema 17 Stepper Motor Bipolar 2A 59Ncm(84oz.in) 48mm Body 4-Lead W/ 1m Cable and Connector Compatible with 3D Printer/CNC: Amazon.com: Tools & Home Improvement