Running a stepper motor with arduino on RAMPS with drv8825 driver

#include <Stepper.h>

int enablePin = 24;
int dirPin = 28;
int stepPin = 26;

void setup() {
  pinMode(enablePin, OUTPUT);
  digitalWrite(enablePin, LOW);
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
}

void step(boolean dir, int steps)
{
  digitalWrite(dirPin, dir);
  delay(50);

  for( int i=0;i<steps;i++)
  {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(800);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(800);

  }
}

void loop() {
  step(true, 1000);
  delay(50);
  step(false, 1000);
  delay(50);
}

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: