Advertisement
RuiViana

StepTB6560

Mar 5th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #define Step 9 // Clk+
  2. #define Dir 8 // Cw+
  3. #define Bota3000 3 // botao
  4. #define Bota5000 4 // botao
  5. #define Bota8000 5 // botao
  6. unsigned int Qtde_Steps = 3000;
  7. unsigned int velocity = 100;
  8.  
  9. //--------------------------------------------
  10. void setup()
  11. {
  12. Serial.begin(9600);
  13. pinMode(Bota3000, INPUT_PULLUP);
  14. pinMode(Bota5000, INPUT_PULLUP);
  15. pinMode(Bota8000, INPUT_PULLUP);
  16. pinMode(Dir, OUTPUT);
  17. pinMode(Step, OUTPUT);
  18. digitalWrite(Dir, LOW);
  19. digitalWrite(Step, LOW);
  20. digitalWrite(Dir, HIGH);
  21. }
  22. //---------------------------------------------
  23. void loop()
  24. {
  25. if (digitalRead(Bota3000) == LOW)
  26. {
  27. for ( int i = 0; i < Qtde_Steps ; i++)
  28. {
  29. digitalWrite(Step, HIGH);
  30. delayMicroseconds(velocity);
  31. digitalWrite(Step, LOW);
  32. delayMicroseconds(velocity);
  33. }
  34. }
  35. if (digitalRead(Bota5000) == LOW)
  36. {
  37. for ( int i = 0; i < (Qtde_Steps+2000) ; i++)
  38. {
  39. digitalWrite(Step, HIGH);
  40. delayMicroseconds(velocity);
  41. digitalWrite(Step, LOW);
  42. delayMicroseconds(velocity);
  43. }
  44. }
  45. if (digitalRead(Bota8000) == LOW)
  46. {
  47. for ( int i = 0; i < (Qtde_Steps+5000) ; i++)
  48. {
  49. digitalWrite(Step, HIGH);
  50. delayMicroseconds(velocity);
  51. digitalWrite(Step, LOW);
  52. delayMicroseconds(velocity);
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement