Need help with an idea

I believe I may have mis represented what I wanted to do; and I apologize for creating a discussion that seems to be an issue with some conflicting ideas. I don't think I ever wanted to call Setup() from my main program. Matter of fact I never even connected Setup() as a function itself until reading these comments! I did learn a little! :slight_smile:

Let me try and clear things up a little bit. As I learn more about C++ programming and the arduino I may be able to better articulate my questions. :slight_smile:

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'?

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?

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.

Hope that made sense.. :slight_smile: