├── README.md └── code1.ino /README.md: -------------------------------------------------------------------------------- 1 | # cnc-shield-v3-uno 2 | Arduino CNC Shield V3 + DRV8825 3 | 4 | [![Maker Tutor](https://img.youtube.com/vi/DZcrrFcs4N4/0.jpg)](https://www.youtube.com/watch?v=DZcrrFcs4N4) 5 | -------------------------------------------------------------------------------- /code1.ino: -------------------------------------------------------------------------------- 1 | // defines pins numbers 2 | 3 | const int stepX = 2; 4 | 5 | const int dirX = 5; 6 | 7 | 8 | 9 | const int stepY = 3; 10 | 11 | const int dirY = 6; 12 | 13 | 14 | 15 | const int stepZ = 4; 16 | 17 | const int dirZ = 7; 18 | 19 | 20 | 21 | const int enPin = 8; 22 | 23 | 24 | 25 | void setup() { 26 | 27 | 28 | 29 | // Sets the two pins as Outputs 30 | 31 | pinMode(stepX,OUTPUT); 32 | 33 | pinMode(dirX,OUTPUT); 34 | 35 | 36 | 37 | pinMode(stepY,OUTPUT); 38 | 39 | pinMode(dirY,OUTPUT); 40 | 41 | 42 | 43 | pinMode(stepZ,OUTPUT); 44 | 45 | pinMode(dirZ,OUTPUT); 46 | 47 | 48 | 49 | pinMode(enPin,OUTPUT); 50 | 51 | digitalWrite(enPin,LOW); 52 | 53 | 54 | 55 | digitalWrite(dirX,HIGH); 56 | 57 | digitalWrite(dirY,LOW); 58 | 59 | digitalWrite(dirZ,HIGH); 60 | 61 | 62 | 63 | } 64 | 65 | void loop() { 66 | 67 | 68 | 69 | // Enables the motor to move in a particular direction 70 | 71 | // Makes 200 pulses for making one full cycle rotation 72 | 73 | for(int x = 0; x < 800; x++) { 74 | 75 | digitalWrite(stepX,HIGH); 76 | 77 | delayMicroseconds(1000); 78 | 79 | digitalWrite(stepX,LOW); 80 | 81 | delayMicroseconds(1000); 82 | 83 | } 84 | 85 | delay(1000); // One second delay 86 | 87 | 88 | 89 | 90 | 91 | for(int x = 0; x < 800; x++) { 92 | 93 | digitalWrite(stepY,HIGH); 94 | 95 | delayMicroseconds(1000); 96 | 97 | digitalWrite(stepY,LOW); 98 | 99 | delayMicroseconds(1000); 100 | 101 | } 102 | 103 | 104 | 105 | delay(1000); // One second delay 106 | 107 | 108 | 109 | for(int x = 0; x < 800; x++) { 110 | 111 | digitalWrite(stepZ,HIGH); 112 | 113 | delayMicroseconds(1000); 114 | 115 | digitalWrite(stepZ,LOW); 116 | 117 | delayMicroseconds(1000); 118 | 119 | } 120 | 121 | 122 | 123 | delay(1000); // One second delay 124 | 125 | 126 | 127 | } 128 | --------------------------------------------------------------------------------