// 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 // 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(); }