Need to Have a mnual Switch in between 2 different functions in an Actuator proj

Hi Arduino Community, I am new to Ardunio and I am working on a school project that is an automated bottle opener and crusher, I have setup my codes with Delay so the actuator extends then the opener does its things and then it retracts up using Delay in the Void setup area by sequencing different relays. ( I know I should probably look into implementing Millis() function but I did not know how to do it!)

I also have a button setup on my bread board where I want to take priority or have a manual switch to turn on if needed before the loop takes over. ( Right now I have to wait till the Void setup code finishes, then in the loop I have the buttons setup so I can manually crush up and down using the actuator)

What I like to do is either have an override key that my buttons move the actuator up and down before the delay codes work for the opening mechanism OR just have a manual switch so I can assign which code to use at the time, Could you please help?

here are the codes I have:

// constants won't change. They're used here to set pin numbers:
const int button1Pin = 1;     // the number of the pushbutton1 pin (Down)
const int button2Pin = 2;     // the number of the pushbutton2 pin (Up)
const int RELAY1 = 6;      // Actuator Retracting
const int RELAY2 = 7;      // Actuator Extending

// variables will change:
int button1State = 0;         // variable for reading the pushbutton status
int button2State = 0;         // variable for reading the pushbutton status

const int sensorPin = 0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor


// initialize the pushbutton pin as an input:

// initialize the relay pin as an output:


const int RELAY3 = 4;      // Bottle Opener reverse
const int RELAY4 = 5;      // Bottle Opener opening

void setup() {

 //start serial connection
 Serial.begin(9600);


 // Initialise the Arduino data pins for OUTPUT
 pinMode(button1Pin, INPUT);
 pinMode(button2Pin, INPUT);
 pinMode(RELAY3, OUTPUT);
 pinMode(RELAY4, OUTPUT);
 pinMode(RELAY1, OUTPUT);
 pinMode(RELAY2, OUTPUT);


 digitalWrite(RELAY1, HIGH);
 delay(3000);
 digitalWrite(RELAY1, LOW);
 delay(1000);
 digitalWrite(RELAY3, LOW);
 delay(1000);
 digitalWrite(RELAY1, LOW);
 delay(1000);
 digitalWrite(RELAY2, HIGH);
 delay(1500);
 digitalWrite(RELAY2, LOW);
 delay(5000);
 digitalWrite(RELAY4, HIGH);
 delay(5500);
 digitalWrite(RELAY4, LOW);
 // Wait 5 seconds to retract + 2 + & - 2 -
 // Turns OFF Relays 2
 delay(5500);
 digitalWrite(RELAY3, HIGH);
 delay(3000);
 digitalWrite(RELAY3, LOW);
 delay(3000);
 
 
 digitalWrite(RELAY1, HIGH);         // Turns Relay On
 delay(2000);                          // Wait 45 seconds to retract + 2 + & - 2 -
 digitalWrite(RELAY2, LOW);
 delay(2000);
 digitalWrite(RELAY3, LOW);
 delay(2000);
 digitalWrite(RELAY4, LOW);          // Turns OFF Relays 2
 delay(2000);
 

}
void loop() {

 // read the value from the sensor:
 sensorValue = analogRead(sensorPin); 
 //print out the value of the pushbutton
 Serial.println(sensorValue);    
 
 // read the state of the pushbutton values:
 button1State = digitalRead(button1Pin);
 button2State = digitalRead(button2Pin);

 // check if the pushbutton1 is pressed.
 // if it is, the buttonState is HIGH:
 // we also ensure tha the other button is not pushed to avoid conflict
 if (button1State == HIGH && button2State == LOW) {     
   // turn relay1 on:    
   digitalWrite(RELAY1, HIGH);     
 } 
 // When we let go of the button, turn off the relay
 else if (digitalRead(RELAY1) == HIGH) {
   // turn relay1 off:
   digitalWrite(RELAY1, LOW); 
 }
 
 // repeat the same procedure for the second pushbutton
 if (button1State == LOW && button2State == HIGH) {     
   // turn relay2 on:    
   digitalWrite(RELAY2, HIGH); 
 } 
 // When we let go of the button, turn off the relay
 else if (digitalRead(RELAY2) == HIGH) {
   // turn relay2 off:
   digitalWrite(RELAY2, LOW); 
 }  
}

Look at how your code is displayed in the forum.

You didn't use code tags to post your code. It's important that you use them - if you don't, the forum software sometimes interprets sequences of characters in the code as directives to format text in some way. It won't display those sequences, and it will unexpectedly reformat the rest of the text. When that happens, and someone tries to copy your code and paste it into the IDE, it often throws an error, and readers will complain that the code fails to compile. Using code tags also makes it easier to read, and can be copied with a single mouse click.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, open it in a text editor, then copy it to the IDE. It's much easier to just view the code in your post.

The code tags make the code look

like this

when posting source code files.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the

[code]and [/code]

metatags.

When you are finished that, please read this post:

How to use this forum - please read.

Thank you, I just put my codes in the right format. Could you help with my question?