Good afternoon,
I have made all the connections following the scheme at the webpage of Pololu but my stepper motor does not respond. It is a NEMA 17 4V 1.8°/step. My purpose is rotating the motor in one single direction a number of steps.
This is the code I am using:
#define STEP_PIN 2
int numberOfSteps = 100;
void setup()
{
digitalWrite(STEP_PIN, LOW);
pinMode(STEP_PIN, OUTPUT);
}
void loop()
{
for(int i = 0; i < numberOfSteps; i++)
digitalWrite(STEP_PIN, HIGH);
delay(250);
digitalWrite(STEP_PIN, LOW);
delay(250);
while(1);
}
Following the instructions of Pololu I have connected the pin DIR to the GND of Arduino, even if I am not interested in using it, the voltage can fluctuate if I leave it without connection.
Apart from this I have tried another code. The motor responds but it does not do what it is written in the code.
Here is the second code:
#include <Stepper.h> //Importamos la librería para controlar motores paso a paso
#define STEPS 200 //Ponemos el número de pasos que necesita para dar una vuelta. 200 en nuestro caso
// Ponemos nombre al motor, el número de pasos y los pins de control
Stepper stepper(STEPS, 2, 3); //Stepper nombre motor (número de pasos por vuelta, pins de control)
void setup()
{
// Velocidad del motor en RPM
stepper.setSpeed(100);
}
void loop()
{
//Girar una vuelta entera en un sentido
stepper.step(200);
delay(500); //Pequeña pausa
//Girar una vuelta entera en sentido contrario
stepper.step(-200);
delay(500); //Pequeña pausa
}
What can be the problem. You have any suggestions to modify the code, in particular the first one?
Thank you