Advertisement
RuiViana

Testa Step

Apr 12th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. int x;
  2. #define Stepx 3
  3. #define Dirx 2
  4. #define Enx 6 // 38
  5.  
  6. // -------------------------------------------
  7. void setup()
  8. {
  9. pinMode(Enx,OUTPUT); // Enable
  10. pinMode(Stepx,OUTPUT); // Step
  11. pinMode(Dirx,OUTPUT); // Dir
  12. digitalWrite(Enx,LOW); // Set Enable low
  13. }
  14. // -------------------------------------------
  15. void loop()
  16. {
  17. digitalWrite(Dirx,HIGH); // Set Dir high
  18. for(x = 0; x < 200; x++) // Loop 200 times
  19. {
  20. digitalWrite(Stepx,HIGH); // Output high
  21. delayMicroseconds(500); // Wait 1/2 a ms
  22. digitalWrite(Stepx,LOW); // Output low
  23. delayMicroseconds(500); // Wait 1/2 a ms
  24. }
  25. delay(1000); // pause one second
  26. digitalWrite(Dirx,LOW); // Set Dir low
  27. for(x = 0; x < 200; x++) // Loop 2000 times
  28. {
  29. digitalWrite(Stepx,HIGH); // Output high
  30. delayMicroseconds(500); // Wait 1/2 a ms
  31. digitalWrite(Stepx,LOW); // Output low
  32. delayMicroseconds(500); // Wait 1/2 a ms
  33. }
  34. delay(1000); // pause one second
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement