PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

29 lines
751B

  1. // Overshoot.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Check overshoot handling
  5. // which sets a new target position and then waits until the stepper has
  6. // achieved it. This is used for testing the handling of overshoots
  7. //
  8. // Copyright (C) 2009 Mike McCauley
  9. // $Id: Overshoot.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
  10. #include <AccelStepper.h>
  11. // Define a stepper and the pins it will use
  12. AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
  13. void setup()
  14. {
  15. stepper.setMaxSpeed(150);
  16. stepper.setAcceleration(100);
  17. }
  18. void loop()
  19. {
  20. stepper.moveTo(500);
  21. while (stepper.currentPosition() != 300) // Full speed up to 300
  22. stepper.run();
  23. stepper.runToNewPosition(0); // Cause an overshoot then back to 0
  24. }