ac5ff:
Am I correct in assuming I can create a function ... we'll call it MirrorHome() ... that will run a set of commands every time it's called. I.E. I want to rotate a stepper CW until I have an input pin go high. Then I want to rotate the stepper CCW 150 steps. That in itself (to me at least) is a whole program. So, could that be a 'function'?
Yes.
ac5ff:
Secondly; lets say I don't want a function at all. But in the Setup() section I have that same bit of code to rotate the mirror/etc. Will that work?
Yes.
ac5ff:
My other thought was to set an int MirrorHome ==0 in the setup. Then in the loop() the first bit of code would be an If(MirrorHome==0); then position the mirror home, then set MirrorHome ==1 That way every time the code looped it would skip this section; but if the program restarts it would reset the mirror to home before beginning.
Yes. This is the "state machine" approach. I would use something like
boolean needToHomeMirror = true;
void loop() {
if(needToHomeMirror) {
home_the_mirror();
}
// etc, etc
}
void home_the_mirror() {
// do whatever you need to do to home the mirror
needToHomeMirror = false;
}