M415 Stepper Motor Driver and Arduino tutorial - zonemaker




Features:

1. Working power supply 9-42V;
2. Maximum drive current 4A;
3. the input signal is high-speed optical insulation;
4. provide semi-automatic current locking function;
5. built-in thermal protection and overcurrent protection.;
6. Designed in a small size and convenient to be installed;
7. maximum power dissipation: 126W
8. 7 subdivision are optional: 1/2A, 2/B, 4, 8, 16, 32





Arduino Sketch

// defines pins numbers
const int dirPin  = 5;
const int stepPin = 4; 
const int enPin   = 6;

void setup() {
  
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);

  pinMode(enPin,OUTPUT);
  digitalWrite(enPin,HIGH);
  
}
void loop() {
  
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 1600; x++) {
    digitalWrite(stepPin,HIGH); 
    delayMicroseconds(500); 
    digitalWrite(stepPin,LOW); 
    delayMicroseconds(500); 
  }
  delay(1000); // One second delay

  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 1600; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(1000);
  }
  delay(1000);
  
}

ความคิดเห็น