// Bipolar motor with A4988 step motor driver
int STEP = 8; 
int DIR = 7;   // Direction

void setup() {
 pinMode(STEP,OUTPUT); 
 pinMode(DIR,OUTPUT);
}
void loop() {
 digitalWrite(DIR,HIGH); // + Direction

 for(int x = 0; x < 200; x++) {  // 200 pulses one revolution
   digitalWrite(STEP,HIGH); 
   delayMicroseconds(700); 
   digitalWrite(STEP,LOW); 
   delayMicroseconds(700); 
 }
 delay(1000); 
 
 digitalWrite(DIR,LOW); // - Direction

 for(int x = 0; x < 400; x++) {  
   digitalWrite(STEP,HIGH);
   delayMicroseconds(700);
   digitalWrite(STEP,LOW);
   delayMicroseconds(700);
 }
 delay(1000);
}

 

// Stepper motor test with TB6600

 void setup() {
       
   pinMode(8,OUTPUT);  //PUL+ 핀 TB6600 driver
   pinMode(9,OUTPUT);  //PUL- 핀
   pinMode(10,OUTPUT); //DIR+ 핀
   pinMode(11,OUTPUT); //DIR- 핀  

   digitalWrite(8,HIGH);
   digitalWrite(9,LOW);
   digitalWrite(10,HIGH);
   digitalWrite(11,LOW);
 }

  void loop() {
   
 digitalWrite(10,HIGH); //DIR+ 핀
 digitalWrite(11,LOW);  //DIR- 핀
    
for( int i=0; i<=1000 ; i++) { 
  digitalWrite(8,LOW); // PUL+ 핀 TB6600 driver
  delayMicroseconds(350);
  digitalWrite(8,HIGH);
 }
delay(1000) ;  

  digitalWrite(10,LOW); //DIR+ 핀
  digitalWrite(11,HIGH);
 
for( int i=0; i<=1000; i++) {  
  digitalWrite(8,LOW); // PUL+ 핀
  delayMicroseconds(350);
  digitalWrite(8,HIGH);
 }
 delay(1000) ;  
}