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.

DualMotorShield.pde 1.3KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // DualMotorShield.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Shows how to run 2 simultaneous steppers
  5. // using the Itead Studio Arduino Dual Stepper Motor Driver Shield
  6. // model IM120417015
  7. // This shield is capable of driving 2 steppers at
  8. // currents of up to 750mA
  9. // and voltages up to 30V
  10. // Runs both steppers forwards and backwards, accelerating and decelerating
  11. // at the limits.
  12. //
  13. // Copyright (C) 2014 Mike McCauley
  14. // $Id: $
  15. #include <AccelStepper.h>
  16. // The X Stepper pins
  17. #define STEPPER1_DIR_PIN 3
  18. #define STEPPER1_STEP_PIN 2
  19. // The Y stepper pins
  20. #define STEPPER2_DIR_PIN 7
  21. #define STEPPER2_STEP_PIN 6
  22. // Define some steppers and the pins the will use
  23. AccelStepper stepper1(AccelStepper::DRIVER, STEPPER1_STEP_PIN, STEPPER1_DIR_PIN);
  24. AccelStepper stepper2(AccelStepper::DRIVER, STEPPER2_STEP_PIN, STEPPER2_DIR_PIN);
  25. void setup()
  26. {
  27. stepper1.setMaxSpeed(200.0);
  28. stepper1.setAcceleration(200.0);
  29. stepper1.moveTo(100);
  30. stepper2.setMaxSpeed(100.0);
  31. stepper2.setAcceleration(100.0);
  32. stepper2.moveTo(100);
  33. }
  34. void loop()
  35. {
  36. // Change direction at the limits
  37. if (stepper1.distanceToGo() == 0)
  38. stepper1.moveTo(-stepper1.currentPosition());
  39. if (stepper2.distanceToGo() == 0)
  40. stepper2.moveTo(-stepper2.currentPosition());
  41. stepper1.run();
  42. stepper2.run();
  43. }