int x=0;
int y=4000;
int z=200;
int STEPX = 2;
int DIRX = 5;
int STEPY = 3;
int DIRY = 6;
int STEPZ = 4;
int DIRZ = 7;
int EN = 8;
void setup()
{
pinMode(EN,OUTPUT); // Enable
pinMode(STEPY,OUTPUT); // Step
pinMode(DIRY,OUTPUT); // Dir
//digitalWrite(EN,LOW); // Set Enable low
pinMode(STEPX,OUTPUT); // Step
pinMode(DIRX,OUTPUT); // Dir
//digitalWrite(EN,LOW); // Set Enable low
pinMode(STEPZ,OUTPUT); // Step
pinMode(DIRZ,OUTPUT); // Dir
//digitalWrite(EN,LOW); // Set Enable low
analogWrite(EN, 0);
}
void loop()
{
//digitalWrite(DIR,HIGH); // Set Dir high
analogWrite(DIRY,255);
analogWrite(DIRX,255);
analogWrite(DIRZ,255);
for(x = 0; x < y; x++) // Loop 200 times
{
//digitalWrite(STEP,HIGH); // Output high
analogWrite(STEPY,255);
analogWrite(STEPX,255);
analogWrite(STEPZ,255);
delayMicroseconds(z); // Wait 1/2 a ms
//digitalWrite(STEP,LOW); // Output low
analogWrite(STEPY,0);
analogWrite(STEPX,0);
analogWrite(STEPZ,0);
delayMicroseconds(z); // Wait 1/2 a ms
}
delay(1000); // pause one second
//digitalWrite(DIR,LOW); // Set Dir low
analogWrite(DIRY,0);
analogWrite(DIRX,0);
analogWrite(DIRZ,0);
for(x = 0; x < y; x++) // Loop 2000 times
{
//digitalWrite(STEP,HIGH); // Output high
analogWrite(STEPY,255);
analogWrite(STEPX,255);
analogWrite(STEPZ,255);
delayMicroseconds(z); // Wait 1/2 a ms
//digitalWrite(STEP,LOW); // Output low
analogWrite(STEPY,0);
analogWrite(STEPX,0);
analogWrite(STEPZ,0);
delayMicroseconds(z); // Wait 1/2 a ms
}
delay(1000); // pause one second
}
/*
int Pin_STEP = A0;
int Pin_DIR = A1;
int en = 38;
void setup()
{
pinMode(Pin_STEP, OUTPUT);
pinMode(Pin_DIR, OUTPUT);
pinMode(en, OUTPUT);
digitalWrite(en, LOW);
}
void loop()
{
digitalWrite(Pin_DIR, true);
digitalWrite(Pin_STEP, HIGH);
delayMicroseconds(700);
digitalWrite(Pin_STEP, LOW);
delayMicroseconds(700);
}*/