DrAzzy:
For a truly emergency stop button, you want something more rigorous than a software solution, ie, so it can still stop everything even if you managed to hang the microcontroller (eg, due to power glitch or software bug). Could a latching button tied to reset be used? (with pullup/pulldown resistors connected externally to ensure that when the board is in reset state, the pins are held in the "safe" configuration?
If it doesn't need to be that rigorous, can't you just poll it in your while loop? Or do those functions you call (which you didn't inlude the code for) have delays in them or otherwise take a long time to execute? If it needs to be more responsive, or if you can't get away from delays or blocking code, use interrupts.
Goto and break are not the right approach.
void conveyor1F ()
{
digitalWrite(conm1, HIGH);
digitalWrite(conm2, HIGH);
delay(delayTime);
//position 1
digitalWrite(conm1,HIGH);
digitalWrite(conm2, LOW);
delay(delayTime);
//pos2
digitalWrite(conm1,LOW);
digitalWrite(conm2, LOW);
delay(delayTime);
//pos3
digitalWrite(conm1,LOW);
digitalWrite(conm2, HIGH);
delay(delayTime);
//pos 4
}
void conveyor2F ()
{
digitalWrite(connm1, HIGH);
digitalWrite(connm2, HIGH);
delay(delayTime);
//position 1
digitalWrite(connm1,HIGH);
digitalWrite(connm2, LOW);
delay(delayTime);
//pos2
digitalWrite(connm1,LOW);
digitalWrite(connm2, LOW);
delay(delayTime);
//pos3
digitalWrite(connm1,LOW);
digitalWrite(connm2, HIGH);
delay(delayTime);
//pos 4
}
void conveyor2R ()
{
digitalWrite(connm1, HIGH);
digitalWrite(connm2, HIGH);
delay(delayTime);
//position 1
digitalWrite(connm1,LOW);
digitalWrite(connm2, HIGH);
delay(delayTime);
//pos 4
digitalWrite(connm1,LOW);
digitalWrite(connm2, LOW);
delay(delayTime);
//pos3
digitalWrite(connm1,HIGH);
digitalWrite(connm2, LOW);
delay(delayTime);
//pos2
}
these are the subroutines i use , very basic . To control a stepper motor
As for the goto, i am not to sure as my project requires me to only use goto() and not interrupt..