SHARE
TWEET

Untitled

a guest Feb 10th, 2016 135 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MakeStepX(int direction, long stepPause){
  2.   StepX += direction;
  3.  
  4.   if(StepX > 3){
  5.     StepX = 0;
  6.   }
  7.   if(StepX < 0){
  8.     StepX = 3;
  9.   }  
  10.  
  11. //You might have to swap the sequence of steps!!!
  12. //If your motor doesn't rotate as expected, try:
  13. // StepX == 0   StepX == 1   StepX == 2   StepX == 3
  14. // 1 0 0 0      0 0 0 1      0 1 0 0      0 0 1 0
  15. // or:
  16. // StepX == 0   StepX == 1   StepX == 2   StepX == 3
  17. // 1 0 0 0      0 0 1 0      0 1 0 0      0 0 0 1
  18. // or:
  19. // StepX == 0   StepX == 1   StepX == 2   StepX == 3
  20. // 1 0 0 0      0 1 0 0      0 0 1 0      0 0 0 1
  21. // or:
  22. // StepX == 0   StepX == 1   StepX == 2   StepX == 3
  23. // 1 0 0 0      0 1 0 0      0 0 0 1      0 0 1 0
  24.  
  25.   if(StepX == 0){
  26.     digitalWrite(X_STEPPER01, 1);
  27.     digitalWrite(X_STEPPER02, 0);
  28.     digitalWrite(X_STEPPER03, 0);
  29.     digitalWrite(X_STEPPER04, 0);    
  30.   }
  31.   if(StepX == 1){
  32.     digitalWrite(X_STEPPER01, 0);
  33.     digitalWrite(X_STEPPER02, 0);
  34.     digitalWrite(X_STEPPER03, 1);
  35.     digitalWrite(X_STEPPER04, 0);    
  36.   }
  37.   if(StepX == 2){
  38.     digitalWrite(X_STEPPER01, 0);
  39.     digitalWrite(X_STEPPER02, 1);
  40.     digitalWrite(X_STEPPER03, 0);
  41.     digitalWrite(X_STEPPER04, 0);    
  42.   }
  43.   if(StepX == 3){
  44.     digitalWrite(X_STEPPER01, 0);
  45.     digitalWrite(X_STEPPER02, 0);
  46.     digitalWrite(X_STEPPER03, 0);
  47.     digitalWrite(X_STEPPER04, 1);    
  48.   }
  49.  
  50.   usleep(stepPause);
  51. }
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