#include <Stepper.h>
#define STEPS 400
Stepper stepper(STEPS, 7, 8, 9, 10);
int previous = 0;
void setup()
{ stepper.setSpeed(30); }
void loop()
{
int footpedal = analogRead(0);
stepper.step(footpedal - previous);
previous = footpedal;
}
This is my Pseudo code.
Power up
Call // Call required functions and libraries needed to control a Stepper
Initialize // Return to nominal slit position at zero degrees
Loop{
Prompt Command (State1,State2,State3,WAITHERE,Powerdown)
// waits for user to command the modules (State1, 2 or 3 at the 300, 0 and 60 degree positions respectively)
Sense current position // Locate what degree the center is pointing at.
Direction option // Is prompt command clockwise or counter clockwise of sense position?
Magnitude // What # number of pulses/ steps is between Sense and Prompt values
Stepper.step// Both commands (direction and # of pulses) are sent to motor shield
Promt User ( Go to State 1,2,3, WAITHERE or power down) })
End program
This post has been edited by macosxnerd101: 28 October 2012 - 09:02 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote


|