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.
31 lines
700 B
31 lines
700 B
7 years ago
|
// Random.pde
|
||
|
// -*- mode: C++ -*-
|
||
|
//
|
||
|
// Make a single stepper perform random changes in speed, position and acceleration
|
||
|
//
|
||
|
// 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()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
if (stepper.distanceToGo() == 0)
|
||
|
{
|
||
|
// Random change to speed, position and acceleration
|
||
|
// Make sure we dont get 0 speed or accelerations
|
||
|
delay(1000);
|
||
|
stepper.moveTo(rand() % 200);
|
||
|
stepper.setMaxSpeed((rand() % 200) + 1);
|
||
|
stepper.setAcceleration((rand() % 200) + 1);
|
||
|
}
|
||
|
stepper.run();
|
||
|
}
|