This is my first Arduino project, so please excuse my lack of knowledge. The following sketch runs a microprocessor controlled stepper motor , therefore using only 2 outputs from the UNO, and a small solid state relay to open dispensing valves. My question is, how can I halt the program loop and then continue the sketch after using the "reset" or other input.
#include <Stepper.h>
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(1000, 8, 9);
void setup() {
stepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
// initialize the digital pins as an output.
// LED On 13 and SSR 7 relay output
pinMode(13, OUTPUT);
pinMode(7, OUTPUT);
//set ST17 back to position P20
pinMode(2, OUTPUT);
}
void loop() {
//press reset button to start sequence?????????????????????
// reset motor to home position of P20 using Evodrive ST-17
digitalWrite(2, HIGH);
delay(200);
digitalWrite(2, LOW);
delay(5000); // wait for home
Serial.println("clockwise");
//move to tube 1
stepper.step(1000);
// turn on LED and SSR relay output
// relay "On" ,Solid State Relay triggered for dispense
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//move to next tube
stepper.step(1000);
// turn on LED and SSR relay output
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);
//dispense time milliseconds
delay(5000);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
delay(1000);
//return tray to home position
Serial.println("counterclockwise");
stepper.step(-10000);
}