HelloStepper.ino 969 B

12345678910111213141516171819202122232425262728293031323334
  1. /*==========================================================================
  2. * This is a minimal sketch showing the usage of TeensyStep
  3. *
  4. * STEP Pulses on Pin 2 (can be any pin)
  5. * DIR Signall on Pin 3 (can be any pin)
  6. *
  7. * The target position is set to 1000 steps relative to the
  8. * current position. The move command of the controller
  9. * moves the motor to the target position.
  10. *
  11. * Default parameters are
  12. * Speed: 800 steps/s
  13. * Acceleration: 2500 steps/s^2
  14. *
  15. * (slow, but good to start with since they will work on any normal stepper)
  16. *
  17. ===========================================================================*/
  18. #include "TeensyStep.h"
  19. Stepper motor(2, 3); // STEP pin: 2, DIR pin: 3
  20. StepControl controller; // Use default settings
  21. void setup()
  22. {
  23. }
  24. void loop()
  25. {
  26. motor.setTargetRel(1000); // Set target position to 1000 steps from current position
  27. controller.move(motor); // Do the move
  28. delay(500);
  29. }