initial fork
This commit is contained in:
40
examples/Quickstop/Quickstop.pde
Normal file
40
examples/Quickstop/Quickstop.pde
Normal file
@ -0,0 +1,40 @@
|
||||
// Quickstop.pde
|
||||
// -*- mode: C++ -*-
|
||||
//
|
||||
// Check stop handling.
|
||||
// Calls stop() while the stepper is travelling at full speed, causing
|
||||
// the stepper to stop as quickly as possible, within the constraints of the
|
||||
// current acceleration.
|
||||
//
|
||||
// Copyright (C) 2012 Mike McCauley
|
||||
// $Id: $
|
||||
|
||||
#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()
|
||||
{
|
||||
stepper.setMaxSpeed(150);
|
||||
stepper.setAcceleration(100);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
stepper.moveTo(500);
|
||||
while (stepper.currentPosition() != 300) // Full speed up to 300
|
||||
stepper.run();
|
||||
stepper.stop(); // Stop as fast as possible: sets new target
|
||||
stepper.runToPosition();
|
||||
// Now stopped after quickstop
|
||||
|
||||
// Now go backwards
|
||||
stepper.moveTo(-500);
|
||||
while (stepper.currentPosition() != 0) // Full speed basck to 0
|
||||
stepper.run();
|
||||
stepper.stop(); // Stop as fast as possible: sets new target
|
||||
stepper.runToPosition();
|
||||
// Now stopped after quickstop
|
||||
|
||||
}
|
Reference in New Issue
Block a user