Created
November 15, 2019 20:02
-
-
Save ptrstovka/89af3ffc1f013eb2e7ef62732ebc1786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defines pins numbers | |
const int stepX = 2; | |
const int dirX = 5; | |
const int stepY = 3; | |
const int dirY = 6; | |
const int stepZ = 4; | |
const int dirZ = 7; | |
const int enPin = 8; | |
void setup() { | |
// Sets the two pins as Outputs | |
pinMode(stepX,OUTPUT); | |
pinMode(dirX,OUTPUT); | |
pinMode(stepY,OUTPUT); | |
pinMode(dirY,OUTPUT); | |
pinMode(stepZ,OUTPUT); | |
pinMode(dirZ,OUTPUT); | |
pinMode(enPin,OUTPUT); | |
digitalWrite(enPin,LOW); | |
digitalWrite(dirX,HIGH); | |
digitalWrite(dirY,LOW); | |
digitalWrite(dirZ,HIGH); | |
} | |
void moveX() { | |
for(int x = 0; x < 800; x++) { | |
digitalWrite(stepX,HIGH); | |
delayMicroseconds(1000); | |
digitalWrite(stepX,LOW); | |
delayMicroseconds(1000); | |
} | |
delay(200); // One second delay | |
} | |
void moveY() { | |
for(int x = 0; x < 800; x++) { | |
digitalWrite(stepY,HIGH); | |
delayMicroseconds(1000); | |
digitalWrite(stepY,LOW); | |
delayMicroseconds(1000); | |
} | |
delay(200); // One second delay | |
} | |
void loop() { | |
digitalWrite(dirX,HIGH); | |
digitalWrite(dirY,LOW); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveY(); | |
moveY(); | |
moveY(); | |
moveY(); | |
digitalWrite(dirX,LOW); | |
digitalWrite(dirY,HIGH); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveX(); | |
moveY(); | |
moveY(); | |
moveY(); | |
moveY(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment