Hi,
I've set up a NEMA 42 motor and a DM2282 driver via a breadboard, to my Arduino Uno.
Please see attached diagram for the setup.
The code I'm using is:
#include <AccelStepper.h>
// defines pins numbers
const int stepPin = 9;
const int dirPin = 8;
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop() {
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 1000 pulses for making one full cycle rotation
for(int x = 0; x < 1000; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000); // One second delay
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 1000 pulses for making two full cycle rotation
for(int x = 0; x < 1000; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
}
Can you tell why it isn't working?
The motor itself receives power so it's probably something in the digital pins or the wiring in the breadboard.
*The resistors are 330 Ohm
Thank you!