diff options
Diffstat (limited to 'Arduino/libraries/AccelStepper/examples/Bounce/Bounce.pde')
| -rw-r--r-- | Arduino/libraries/AccelStepper/examples/Bounce/Bounce.pde | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Arduino/libraries/AccelStepper/examples/Bounce/Bounce.pde b/Arduino/libraries/AccelStepper/examples/Bounce/Bounce.pde new file mode 100644 index 0000000..6073c53 --- /dev/null +++ b/Arduino/libraries/AccelStepper/examples/Bounce/Bounce.pde @@ -0,0 +1,29 @@ +// Bounce.pde +// -*- mode: C++ -*- +// +// Make a single stepper bounce from one limit to another +// +// Copyright (C) 2012 Mike McCauley +// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $ + +#include <AccelStepper.h> + +// Define a stepper and the pins it will use +AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5 + +void setup() +{ + // Change these to suit your stepper if you want + stepper.setMaxSpeed(100); + stepper.setAcceleration(20); + stepper.moveTo(500); +} + +void loop() +{ + // If at the end of travel go to the other end + if (stepper.distanceToGo() == 0) + stepper.moveTo(-stepper.currentPosition()); + + stepper.run(); +} |
