1

Topic: Using the Azteeg X3 for something other than printing.

Hello, I'm not sure if this is the best place to post this, but I'm doing so anyway big_smile! I have an Azteeg X3 that I am using to control some stepper motors on a door lock, but for the life of me, I cannot figure out how to code the stepper motor drivers properly. I might not have the right pins or something. Currently, I have a single stepper motor hooked up to the X-Axis and I have a desktop PSU properly supplying power to the board. Anyway, here is the code I am trying:

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// as posted on Arduino Forum at link

byte directionPin = 28;
byte stepPin = 26;
byte enable = 24;
int numberOfSteps = 100;
byte ledPin = 6;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 25; // milliseconds


void setup() 
{ 

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
   pinMode(enable, OUTPUT);
  
  digitalWrite(directionPin, HIGH);
  digitalWrite(enable, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros);
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
}

void loop() 
{ 

}