Here is the user manual for the BH-MSD-2A Micro stepping driver.
Page 5 shows the two tables giving the connections:
You have already connected P2, and that leaves P1 remaining.
The timing diagram below shows the state of the, PUL
, DIR
and ENA
signals required
.
So, the ENA
input can either be held high, by connecting to VCC or connected to a digital output pin of the Arduino, to provide basic ON/OFF control.
This thread, arduino uno with stepper motor, the OP is using a very similar controller to yours, except that theirs is the 6 A version (BH-MSD-6A). Their code, in the thread has a lot of unnecessary code, and apparently has a number of issues. A stripped down version, of the same code, is as follows:
//arduino code
//
#include <TimerOne.h>
#include <EEPROM.h>
int rpm;
int initial_rpm;
int dutycycle_time=0;
int stepper_Enable=5; //STEPPER MOTOR ENABLE PIN : PUL-
int stepper_Pulse=6; // STEPPER MOTOR PULSE PIN : PUL-
int address_eeprom=0;
void displayNumber(int);
void lightNumber(int);
void setup()
{
Timer1.attachInterrupt( timerIsr ); // attach the service routine here
pinMode(stepper_Pulse,OUTPUT); // Analog pin A2 is used for ENABLING the steeper motor
pinMode(stepper_Enable,OUTPUT); // Analog pin A2 is used for DIRECTION the steeper motor
digitalWrite(stepper_Pulse,HIGH);
digitalWrite(stepper_Enable,LOW);
rpm=EEPROM.read(address_eeprom);
}
void loop()
{
while(digitalRead(stepper_Enable)==HIGH){
int cycle_freq=(1600/60)*rpm;
int dutycycle_freq=2*cycle_freq;
int dutycycle_time=1000000/dutycycle_freq;
Timer1.initialize(dutycycle_time); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)
if(analogRead(A3)==LOW ) // STOPPING THE STEPPER MOTOR
{
digitalWrite(stepper_Enable,LOW);
}
}
while(digitalRead(stepper_Enable)==LOW)
{
int initial_rpm=rpm;
EEPROM.write(address_eeprom,rpm);
if(analogRead(A0)==LOW && rpm<300 ) ///increasing speed of stepper motor
{
rpm=rpm+1;
// delay(100);
}
if(analogRead(A1)==LOW && rpm>0) ///decreasing speed of stepper motor
{
rpm=rpm-1;
// delay(100);
}
if(analogRead(A2)==LOW ) //STARTING THE STEPPER MOTOR
{
digitalWrite(stepper_Enable,HIGH);
}
}
if(initial_rpm!=rpm){
address_eeprom=address_eeprom+1;
}
}
void timerIsr()
{
// Toggle LED
digitalWrite( stepper_Pulse, !digitalRead( stepper_Pulse ));
}
Note that while this should get you started, as the OP states in the thread there are issues with it, that will need fixing.
(I have to go now to fix some Marlin firmware, but I'll come back to this answer later)