Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. const int dirPin = 8;
  2. const int stepPin = 9;
  3.  
  4. const int steps = 200;
  5. int stepDelay;
  6.  
  7. void setup() {
  8. // Marcar los pines como salida
  9. pinMode(dirPin, OUTPUT);
  10. pinMode(stepPin, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14. //Activar una direccion y fijar la velocidad con stepDelay
  15. digitalWrite(dirPin, HIGH);
  16. stepDelay = 250;
  17. // Giramos 200 pulsos para hacer una vuelta completa
  18. for (int x = 0; x < 200; x++) {
  19. digitalWrite(stepPin, HIGH);
  20. delayMicroseconds(stepDelay);
  21. digitalWrite(stepPin, LOW);
  22. delayMicroseconds(stepDelay);
  23. }
  24. delay(1000);
  25.  
  26. //Cambiamos la direccion y aumentamos la velocidad
  27. digitalWrite(dirPin, LOW);
  28. stepDelay = 150;
  29. // Giramos 400 pulsos para hacer dos vueltas completas
  30. for (int x = 0; x < 400; x++) {
  31. digitalWrite(stepPin, HIGH);
  32. delayMicroseconds(stepDelay);
  33. digitalWrite(stepPin, LOW);
  34. delayMicroseconds(stepDelay);
  35. }
  36. delay(1000);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement