Hi all,
I have my stepper motor code which controls a pitch and yaw stepper motors. The code for the yaw (X) stepper works fine however I am having issues with my pitch (Y) stepper which has a step angle of 0.018 degrees.
My problem is that I need my pitch stepper to rotate 45 degrees in total at 5 degree motions. It can rotate after the yaw stepper does a full sweep. I tried to limit the pitch angle by using a += logic but that didnt work.
Is there anyway I can stop the pitch stepper motor once it has rotated a total of 45 degrees (2500 steps) after doing nine rotations at 5 degrees a time once a 120 degree yaw (X) sweep has been finished.
Below is my code, and thank you for taking the time to help.
Jacob.
// Include the Arduino Stepper Library
#include <Stepper.h>
int posX = 0; // Yaw stepper
int posY = 0; // Pitch stepper
// Number of steps per output rotation
const int stepsPerRevolution = 200;
// Create Instance of Stepper library
Stepper XStepper(stepsPerRevolution, 4, 5, 6, 7);
Stepper YStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup()
{
// set the speed at 60 rpm:
XStepper.setSpeed(60);
YStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}
void loop()
{
// step one revolution in one direction:
for(posX = 0; posX = 1000; posX = 111)
{
XStepper.step(posX);
if (posY <=2500) {
posY += 278;
YStepper.step(-posY);}
XStepper.step(-posX);
}
}