const byte HomeSwitch = 8;
void setup() {
.
.
.
// running a stepper motor CCW until it trips a switch (pin8).
while (digitalRead(HomeSwitch)) {
// Switch open, so step
step_one_step_CCW();
}
// Once at that position I want to rotate CW 10 steps.
for (int i=0 ; i < 10; i++) {
step_one_stap_CW();
}
}
Typically the homing should start with moving AWAY from home if the home switch is already pressed:
while (!digitalRead(HomeSwitch)) {
// Switch closed, so step away
step_one_step_CW();
}