Program steppen motor

Hello,

I want to make a feeder for bags (school project)
I have a steppen motor with drive and i need a program to start and stop the motor.
The speed need to be fixed in the program.

im totally new to arduino so can someone help me?

I can use this wiring diagram ofcourse with start button.

im using this driver:
see attach

i have a Arduino Mega 2560

Thank you in advance !

Driver ZDM-2HA865 Manual Specification.pdf (653 KB)

These links may help

Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

...R

image missing and nobody will look at scribd.com for anything, so post the pdf.

Robin2:
These links may help

Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

...R

Thank you! i will look at it

Robin2:
These links may help

Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

...R

I have it working. i used your code.
What is prevStepMillis doing?

// testing a stepper motor with a Pololu A4988 driver board or equivalent

// this version uses millis() to manage timing rather than delay()
// and the movement is determined by a pair of momentary push switches
// press one and it turns CW, press the other and it turns CCW

byte directionPin = 9;
byte stepPin = 8;

byte buttonCWpin = 10;
byte buttonCCWpin = 11;

boolean buttonCWpressed = false;
boolean buttonCCWpressed = false;

byte ledPin = 13;

unsigned long curMillis;
unsigned long prevStepMillis = 0;
unsigned long millisBetweenSteps = 25; // milliseconds

void setup() { 

    Serial.begin(9600);
    Serial.println("Starting Stepper Demo with millis()");

    pinMode(directionPin, OUTPUT);
    pinMode(stepPin, OUTPUT);
    pinMode(ledPin, OUTPUT);
    
    pinMode(buttonCWpin, INPUT_PULLUP);
    pinMode(buttonCCWpin, INPUT_PULLUP);
    
}

void loop() { 
   
   curMillis = millis();
   readButtons();
   actOnButtons();
   
}

void readButtons() {
   
   buttonCCWpressed = false;
   buttonCWpressed = false;
   
   if (digitalRead(buttonCWpin) == LOW) {
       buttonCWpressed = true;
   }
   if (digitalRead(buttonCCWpin) == LOW) {
       buttonCCWpressed = true;
   }
}

void actOnButtons() {
   if (buttonCWpressed == true) {
       digitalWrite(directionPin, LOW);
       singleStep();
   }
   if (buttonCCWpressed == true) {
       digitalWrite(directionPin, HIGH);
       singleStep();
   }
}

void singleStep() {
   if (curMillis - prevStepMillis >= millisBetweenSteps) {
           // next 2 lines changed 28 Nov 2018
       //prevStepMillis += millisBetweenSteps;
       prevStepMillis = curMillis;
       digitalWrite(stepPin, HIGH);
       digitalWrite(stepPin, LOW);
   }
}

wasbever:
I have it working. i used your code.
What is prevStepMillis doing?

It records the time when the previous step happened.

...R

PS ... When posting code please use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor See How to use the forum