From d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:55:07 +0200 Subject: Add new code Signed-off-by: Carlos Maiolino --- .../AccelStepper/examples/Overshoot/Overshoot.pde | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Arduino/libraries/AccelStepper/examples/Overshoot/Overshoot.pde (limited to 'Arduino/libraries/AccelStepper/examples/Overshoot') diff --git a/Arduino/libraries/AccelStepper/examples/Overshoot/Overshoot.pde b/Arduino/libraries/AccelStepper/examples/Overshoot/Overshoot.pde new file mode 100644 index 0000000..7e16baf --- /dev/null +++ b/Arduino/libraries/AccelStepper/examples/Overshoot/Overshoot.pde @@ -0,0 +1,28 @@ +// Overshoot.pde +// -*- mode: C++ -*- +// +// Check overshoot handling +// which sets a new target position and then waits until the stepper has +// achieved it. This is used for testing the handling of overshoots +// +// Copyright (C) 2009 Mike McCauley +// $Id: Overshoot.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $ + +#include + +// 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.runToNewPosition(0); // Cause an overshoot then back to 0 +} -- cgit v1.2.3