0 Replies - 734 Views - Last Post: 28 October 2012 - 02:07 PM Rate Topic: -----

#1 kbmcmorrow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-October 12

Arduino Nano for bipolar-stepper footpedal input

Posted 28 October 2012 - 02:07 PM

How can I adapt this to have a footpedal control a stepper to rotate between three specifc states?

#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


Is This A Good Question/Topic? 0
  • +

Page 1 of 1