/*
Stepper Motor Tester v1 @Kunal Panchal
Board - Arduino Uno R3
Test motor - Stepper motor from 0.1 - 10 Amps
Driver everelettronica LW3D2030N2A1 & LW3D3070N0A1
*/
//Define Pins
int driverPLS = 7; // PLS- pin
int driverDIR = 6; // DIR- pin
int Count = 0;
int Stop = 11;
void setup() {
Serial.begin(115200);
pinMode (driverPLS, OUTPUT);
pinMode (driverDIR, OUTPUT);
pinMode (Stop, INPUT);
}
void CW (){
digitalWrite(driverDIR,HIGH); //Direction Signal
digitalWrite(driverPLS,HIGH); //Pulse Signal 1
delay(200);
digitalWrite(driverPLS,LOW); //Pulse Signal 0
delay(200);
}
void CCW (){
digitalWrite(driverDIR,LOW); //Direction Signal
digitalWrite(driverPLS,HIGH); //Pulse Signal 1
delay(200);
digitalWrite(driverPLS,LOW); //Pulse Signal 0
delay(200);
}
void loop(){
delay(2000);
if (digitalRead(Stop) != HIGH){
Serial.println("ON");
}
if(digitalRead(Stop) == HIGH){
Serial.println("OFF") ;
}
if (digitalRead(Stop) != HIGH){
while (Count <= 5){ //Number of Pulse for Clockwise Rotation
CW();
Count++;
}
Count = 0;
delay(1000);
while (Count <= 5){ //Number of Pulse for CounterClockwise Rotation
CCW();
Count++;
}
Count = 0;
delay(1000);
}
else{
delay(2000);
}
}