PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 line
1.1KB

  1. // MultiStepper.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Shows how to multiple simultaneous steppers
  5. // Runs one stepper forwards and backwards, accelerating and decelerating
  6. // at the limits. Runs other steppers at the same time
  7. //
  8. // Copyright (C) 2009 Mike McCauley
  9. // $Id: MultiStepper.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
  10. #include <AccelStepper.h>
  11. // Define some steppers and the pins the will use
  12. AccelStepper stepper1; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
  13. AccelStepper stepper2(AccelStepper::FULL4WIRE, 6, 7, 8, 9);
  14. AccelStepper stepper3(AccelStepper::FULL2WIRE, 10, 11);
  15. void setup()
  16. {
  17. stepper1.setMaxSpeed(200.0);
  18. stepper1.setAcceleration(100.0);
  19. stepper1.moveTo(24);
  20. stepper2.setMaxSpeed(300.0);
  21. stepper2.setAcceleration(100.0);
  22. stepper2.moveTo(1000000);
  23. stepper3.setMaxSpeed(300.0);
  24. stepper3.setAcceleration(100.0);
  25. stepper3.moveTo(1000000);
  26. }
  27. void loop()
  28. {
  29. // Change direction at the limits
  30. if (stepper1.distanceToGo() == 0)
  31. stepper1.moveTo(-stepper1.currentPosition());
  32. stepper1.run();
  33. stepper2.run();
  34. stepper3.run();
  35. }