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.

3 年之前
12345678910111213141516171819202122232425262728
  1. // Blocking.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Shows how to use the blocking call runToNewPosition
  5. // Which sets a new target position and then waits until the stepper has
  6. // achieved it.
  7. //
  8. // Copyright (C) 2009 Mike McCauley
  9. // $Id: Blocking.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(200.0);
  16. stepper.setAcceleration(100.0);
  17. }
  18. void loop()
  19. {
  20. stepper.runToNewPosition(0);
  21. stepper.runToNewPosition(500);
  22. stepper.runToNewPosition(100);
  23. stepper.runToNewPosition(120);
  24. }