29 lines
667 B
Plaintext
29 lines
667 B
Plaintext
// Blocking.pde
|
|
// -*- mode: C++ -*-
|
|
//
|
|
// Shows how to use the blocking call runToNewPosition
|
|
// Which sets a new target position and then waits until the stepper has
|
|
// achieved it.
|
|
//
|
|
// Copyright (C) 2009 Mike McCauley
|
|
// $Id: HRFMessage.h,v 1.1 2009/08/15 05:32:58 mikem Exp mikem $
|
|
|
|
#include <AccelStepper.h>
|
|
|
|
// Define a stepper and the pins it will use
|
|
AccelStepper stepper; // Defaults to 4 pins on 2, 3, 4, 5
|
|
|
|
void setup()
|
|
{
|
|
stepper.setMaxSpeed(200.0);
|
|
stepper.setAcceleration(100.0);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
stepper.runToNewPosition(0);
|
|
stepper.runToNewPosition(500);
|
|
stepper.runToNewPosition(100);
|
|
stepper.runToNewPosition(120);
|
|
}
|