It was late last night when I posted this and I was tired and frustrated. LOL I should have added more details. Sorry!
Below is a look at what I've currently written and trying. What I found was I was putting for loops within for loops which wouldn't compile. So I thought I would do part as a function. Didn't work! LOL
What is this code doing? I'm not sure. The remaining part of the program basically moves the stepper back and forth 10 positions. Before adding all of this; that part of the code works great.
When I add this the stepper moves but is not smooth; it jerks backwards a few steps then forward a couple times, and slowly moves the center of the rotation CCW... Not sure how else to explain that.
Tom:
I've got a Nema17 Stepper using the stepper.h library and Arduino Uno
krupski:
Not sure I understand this line:
uint8_t motorHome; // C clears the vars to zero each time program starts
I'll have to read up on that one. But what you are describing is pretty much what I'm trying to do.
John:
I understand what you are saying about moving away from the home position to start. That's something I'd considered but haven't implemented yet as I've always pre-positioned the stepper motor myself before starting the program. I'd agree that this should be in the working program but at this point I would just like to get this section working to where I need it to be...
void MirrorCenter() // Function to rotate CCW until switch is triggered
{
MirrorPinRead = digitalRead(MirrorPin)
while ((MirrorPositioned = 0) && (MirrorPinRead = LOW));
myStepper.step(-1);
delay(200);
}
void loop() {
MirrorCenter();
if (MirrorPositioned = 0) { // run this section ONCE ONLY; ignore it on every loop except at startup
for (int x=0; x<10; x++);
myStepper.step(1);
}
MirrorPositioned = 1;
}