help optimising my code to run more smoothly on arduino uno.

const int OFF = 11;
const int ACC = 12;
const int START = 13;
const int RFID = 9;
const int BUTTON = 10;
int val_rfid = 0;
int val_button = 0;
int count = 0;
int state = 0;
int state2 = 0;
unsigned long startTime = 0;
void setup() {
  pinMode(OFF, OUTPUT); // RED LED OUTPUT
  pinMode(ACC, OUTPUT); // GREEN LED OUTPUT
  pinMode(START, OUTPUT); //GREEN LED OUTPUT
  pinMode(RFID, INPUT); //BUTTON INPUT (WILL BE REPLACED WITH RFID)
  pinMode(BUTTON, INPUT); //BUTTON INPUT
  Serial.begin(9600);
}

void loop() {
  val_rfid = digitalRead(RFID); // READ PIN 9
  val_button = digitalRead(BUTTON); // READ PIN 10
  startTime = millis();
  count = 0;
if (state != 0){
  digitalWrite(OFF, LOW);
}else{
  digitalWrite(OFF, HIGH);
}
if ((state2 == 1) && (val_rfid == HIGH) && (val_button == HIGH)){
   digitalWrite(START, HIGH);
  }else{
    digitalWrite(START, LOW);
  }
  if ((val_rfid + val_button) == 2){ //checks if both buttons are pressed
 state = 1;
 }
if (state == 1){
  digitalWrite(OFF, LOW);
  digitalWrite(ACC, HIGH);
  state2 = 1;
  delay(500);
}else{
  digitalWrite(OFF, HIGH);
  digitalWrite(ACC, LOW);
}
if ((val_button == HIGH) && (val_rfid == LOW)) {
  delay(1000);
  count++;
  delay(1000);
  count++;
  delay(1000);
  count++;
  }
 if (count == 3) {
  state = 0;
  state2 = 0;
 }
 Serial.println(count);
}

i have wrote my first program and im fairly happy with how its turned out however i feel that my code could be optimised abit as there are many delays in the program. i want to make sure that the START LED has to wait before it can come on after the ACC LED. i also feel that the way i have done the count to reset the program isnt very good. any help would be much appreciated.

thanks

Explain first what your code is supposed to do...

I'd modify the declaration this way for readability. (and also press ctrl-T for proper indentation of the code)

const byte OFFPin = 11;
const byte ACCPin = 12;
const byte STARTPin = 13;
const byte RFIDPin = 9;
const byte BUTTONPin = 10;

you don't need to initialize global to 0, the compiler does it for you (but it does not hurt to be clear).

why do you do this at the start of the loop

if (state != 0){
  digitalWrite(OFF, LOW);
}else{
  digitalWrite(OFF, HIGH);
}

and microseconds later possibly change the value of state and change again the status of the OFF pin?

  if ((val_rfid + val_button) == 2){ //checks if both buttons are pressed
 state = 1;
 }

...

if (state == 1){
  digitalWrite(OFF, LOW);
  digitalWrite(ACC, HIGH);
  state2 = 1;
  delay(500);
}else{
  digitalWrite(OFF, HIGH);
  digitalWrite(ACC, LOW);
}

what are you trying to achieve with this?

if ((val_button == HIGH) && (val_rfid == LOW)) {
  delay(1000);
  count++;
  delay(1000);
  count++;
  delay(1000);
  count++;
  }

There are 2 push buttons and 3 leds(1 red and 2 green) the 2 green leds will later be conntected to relays and one of the push buttons to an rfid. but i just wanted to get a feel for how to use it. initally the red LED is on signling that both green LEDs are off(in future both relays are off). when both buttons are pressed it turns the RED LED off and the first green LED ON (labelled ACC) but i wanted it to delay before it allowed you to turn the second LED(labelled START) on. the second LED i only wanted to come on after the first LED was on and when buttons were held. then when the button labelled RFID isnt on and the button labelled BUTTON is held for 3 seconds it turns the green LEDs off and the red LED on.

the first part of the code is what i did to just turn the red LED on if any of the others were off. this is so that its on at the start of the program. it meant that later on i could set the state back to 0 to turn it back.

what i was trying to achive with the last bit was that when the button labelled RFID was off and the other button was held for 3 seconds it would reset both states to 0 turing the green LEDs off and the red LED on.