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.

Bounce.pde 683B

3 jaren geleden
1234567891011121314151617181920212223242526272829
  1. // Bounce.pde
  2. // -*- mode: C++ -*-
  3. //
  4. // Make a single stepper bounce from one limit to another
  5. //
  6. // Copyright (C) 2012 Mike McCauley
  7. // $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
  8. #include <AccelStepper.h>
  9. // Define a stepper and the pins it will use
  10. AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
  11. void setup()
  12. {
  13. // Change these to suit your stepper if you want
  14. stepper.setMaxSpeed(100);
  15. stepper.setAcceleration(20);
  16. stepper.moveTo(500);
  17. }
  18. void loop()
  19. {
  20. // If at the end of travel go to the other end
  21. if (stepper.distanceToGo() == 0)
  22. stepper.moveTo(-stepper.currentPosition());
  23. stepper.run();
  24. }