SHARE
TWEET

Untitled

a guest Mar 26th, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define enable  8  
  2. #define xDir    5
  3. #define xstep   2
  4.  
  5. int steps = 3200;
  6. int stepDelay = 60;
  7.  
  8. void step (boolean dir, byte dirPin, byte steperPin, int steps)
  9.  
  10. {
  11.  
  12.   digitalWrite(dirPin, dir);
  13.   delay(100)
  14.  
  15.   for (int i=0;1<steps; i++)
  16.   {
  17.   digitalWrite(stepperPin,HIGH);
  18.   delayMicroseconds(stepDelay);
  19.   digitalWrite(stepperPin,LOW);
  20.   delayMicroseconds(stepDelay);
  21.   }
  22. }
  23. void setup() {
  24.   pinMode (xDir,OUTPUT);
  25.   pinMode(xStep,OUTPUT);
  26.   pinMode(enable,OUTPUT);
  27.   digitalWrite(enable,LOW);
  28.   // put your setup code here, to run once:
  29.  
  30. }
  31.  
  32. void loop() {
  33.  
  34.  
  35.   step(false,xDir,xStep,800);
  36.   delay(2000);
  37.   step(true,xDir,xStep,3200);
  38.   delay(2000);
  39.   // put your main code here, to run repeatedly:
  40.  
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top