chirstmass drag tree

Hello I am new to this forum, I am working on a project and just wanted to make sure I had the code right

can anyone tell me of any mistakes or if it is understandable or is there any way to simplify it

void setup() {

  Serial.begin(9600);
  pinMode(1, OUTPUT); // pre stage white
  pinMode(2, OUTPUT); // stage white
  pinMode(4, OUTPUT); // Yellow one
  pinMode(6, OUTPUT); // Yellow two
  pinMode(8, OUTPUT); // Yellow three
  pinMode(10, OUTPUT); // Green
  pinMode(11, OUTPUT); // Red
}

void loop() {
  int analogValue1 = analogRead(A0);
  int analogValue2 = analogRead(A1);
  Serial.print("Analog reading = ");
  Serial.print(analogValue);   // the raw analog reading
  if (analogValue1 < 10) { // if laser is interupted turn on white led
    digitalWrite (1, High)
  }

  if (analogValue2 < 10) {
    digitalWrite(2, HIGH);  // stage White Led on for 2 second
    delay(2000);
    digitalWrite(2, LOW);   // stage White LED turns off for 1/2 second
    delay(500);
    digitalWrite(1, LOW);   // pre stage White LED turns off for 1/2 second
    delay(500)
  }

  if  (analogValue2 < 10) {
    digitalWrite(4, HIGH);  // Yellow led on 1/2 second
    delay(500)
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on

  if  (analogValue2 < 10) {
    digitalWrite(4, LOW);   // Yellow LED turns off for 1/2 second
    delay(500)
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(6, HIGH);  // Yellow Led on for 1/2 second
    delay(500)
  }
  else {
    digitalWrite(11, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(6, LOW);   // LED turns off for 1/2 second
    delay(500)
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on


  if (analogValue2 < 10) {
    digitalWrite(8, HIGH);  // Yellow Led on for 1/2 sec
    delay(500)
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(8, LOW); // Yellow LED turns off for 1/2 second
    delay (500)
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(10, HIGH);  //Green led turns on
  }

  else {
    digitalWrite(11, HIGH)
  }  //Red Led on


}

void setup()

{ Serial.begin(9600); analogRead(A0); // this is the start laser

  analogRead(A3); // this is the stop laser

  Serial.println("");
} //Here you can change the message your stopwatch will display before any buttons are pressed. Put the instructions here for people who have never used your stopwatch to instantly know what to do.

void displayResult()

{ float h, m, s, ms; unsigned long over; elapsed = finished - start; h = int(elapsed / 3600000); over = elapsed % 3600000; m = int(over / 60000); over = over % 60000; s = int(over / 1000); ms = over % 1000; Serial.print("Milliseconds so far: "); //The tekst that will be displayed before the amount of milliseconds passed.

  Serial.println(elapsed); Serial.print("Elapsed time: "); //The text that will be displayed before the amout of time elapsed.

  Serial.print(h, 0); Serial.print("h "); Serial.print(m, 0); Serial.print("m "); Serial.print(s, 0); Serial.print("s "); Serial.print(ms, 0); Serial.println("ms"); Serial.println();
}

void loop()

{ if (analogRead(A0) < 10) {
    start = millis(); delay(200); // for debounce Serial.println("Ready, set, go!"); } //Here you establish what happens when the first button is pressed and the message that it will display to the user

    if (analogRead(A3) > 10) {
      finished = millis(); delay(200); // for debounce displayResult(); } } // here you establish what happens when the second button is pressed and the message that will be displayed.

Upload it to your arduino, if it gives the expected results, it's correct.

Read the first topics like: "How to use this forum", especially how to post code. Autoformat the code in the IDE, use code tags, the symbol up and left, and paste the code in the code tags. Your code is hardly worth reading this way.

  Serial.begin(9600);
  pinMode(1, OUTPUT); // pre stage white

First mistake: Pins 0 and 1 are the Serial interface. You can't use Serial and also use Pin 1 for other stuff. Pick a different pin for your white LED.

Style hint: Use MEANINGFUL NAMES for your pin numbers.

const byte PreStageWhiteLEDPin = 12;

void setup()
{
  pinMode(PreStageWhiteLEDPin, OUTPUT);

This makes it much easier to understand the sketch AND allows you to change pin numbers without editing the whole sketch (like when you find out you can't use Pin 1 for I/O when using Serial).

I modified the code to look like this after the style advice and the serial pin

const byte PreStageWhiteLEDPin = 12;
const byte StageWhiteLEDPin = 2;
const byte YellowoneLEDPin = 4;
const byte YellowtwoLEDPin = 6;
const byte YellowthreeLEDPin = 8;
const byte GreenLEDPin = 10;
const byte RedLEDPin = 11;
void setup() {

  Serial.begin(9600);
  pinMode(PreStageWhiteLEDPin, OUTPUT); // pre stage white
  pinMode(StageWhiteLEDPin, OUTPUT); // stage white
  pinMode(YellowoneLEDPin, OUTPUT); // Yellow one
  pinMode(YellowtwoLEDPin, OUTPUT); // Yellow two
  pinMode(YellowthreeLEDPin, OUTPUT); // Yellow three
  pinMode(GreenLEDPin, OUTPUT); // Green
  pinMode(RedLEDPin, OUTPUT); // Red
}

void loop() {
  int analogValue1 = analogRead(A0);
  int analogValue2 = analogRead(A1);
  Serial.print("Analog reading = ");
  Serial.print(analogValue);   // the raw analog reading
  if (analogValue1 < 10) { // if laser is interupted turn on white led
    digitalWrite (PreStageWhiteLEDPin, High)
  }

  if (analogValue2 < 10) {
    digitalWrite(StageWhiteLEDPin, HIGH);  // stage White Led on for 2 second
    delay(2000);
    digitalWrite(StageWhiteLEDPin, LOW);   // stage White LED turns off for 1/2 second
    delay(500);
    digitalWrite(PreStageWhiteLEDPin, LOW);   // pre stage White LED turns off for 1/2 second
    delay(500)
  }

  if  (analogValue2 < 10) {
    digitalWrite(YellowoneLEDPin, HIGH);  // Yellow led on 1/2 second
    delay(500)
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on

  if  (analogValue2 < 10) {
    digitalWrite(YellowoneLEDPin, LOW);   // Yellow LED turns off for 1/2 second
    delay(500)
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(YellowtwoLEDPin, HIGH);  // Yellow Led on for 1/2 second
    delay(500)
  }
  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(YellowtwoLEDPin, LOW);   // LED turns off for 1/2 second
    delay(500)
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on


  if (analogValue2 < 10) {
    digitalWrite(YellowthreeLEDPin, HIGH);  // Yellow Led on for 1/2 sec
    delay(500)
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(YellowthreeLEDPin, LOW); // Yellow LED turns off for 1/2 second
    delay (500)
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on

  if (analogValue2 < 10) {
    digitalWrite(GreenLEDPin, HIGH);  //Green led turns on
  }

  else {
    digitalWrite(RedLEDPin, HIGH)
  }  //Red Led on


}

void setup()

{ Serial.begin(9600); analogRead(A0); // this is the start laser

  analogRead(A3); // this is the stop laser

  Serial.println("");
} //Here you can change the message your stopwatch will display before any buttons are pressed. Put the instructions here for people who have never used your stopwatch to instantly know what to do.

void displayResult()

{ float h, m, s, ms; unsigned long over; elapsed = finished - start; h = int(elapsed / 3600000); over = elapsed % 3600000; m = int(over / 60000); over = over % 60000; s = int(over / 1000); ms = over % 1000; Serial.print("Milliseconds so far: "); //The text that will be displayed before the amount of milliseconds passed.

  Serial.println(elapsed); Serial.print("Elapsed time: "); //The text that will be displayed before the amout of time elapsed.

  Serial.print(h, 0); Serial.print("h "); Serial.print(m, 0); Serial.print("m "); Serial.print(s, 0); Serial.print("s "); Serial.print(ms, 0); Serial.println("ms"); Serial.println();
}

void loop()

{ if (analogRead(A0) < 10) {
    start = millis(); delay(200); // for debounce Serial.println("Ready, set, go!"); } //Here you establish what happens when the first laser is interrupted and the message that it will display to the user

    if (analogRead(A3) > 10) {
      finished = millis(); delay(200); // for debounce displayResult(); } } // here you establish what happens when the second laser is interrupted and the message that will be displayed.

You have more than one setup() & loop()!

Style hint: It is generally bad style to put more than one statement on a line. For example, this function is almost impossible to understand:

void displayResult()
{ float h, m, s, ms; unsigned long over; elapsed = finished - start; h = int(elapsed / 3600000); over = elapsed % 3600000; m = int(over / 60000); over = over % 60000; s = int(over / 1000); ms = over % 1000; Serial.print("Milliseconds so far: "); //The tekst that will be displayed before the amount of milliseconds passed.
  Serial.println(elapsed); Serial.print("Elapsed time: "); //The text that will be displayed before the amout of time elapsed.
  Serial.print(h, 0); Serial.print("h "); Serial.print(m, 0); Serial.print("m "); Serial.print(s, 0); Serial.print("s "); Serial.print(ms, 0); Serial.println("ms"); Serial.println();
}

This is a clearer way to write it.
Note: You were saving ‘int’ values into ‘float’ variables and then telling .print() to show the float variables without any decimal digits. It is good practice to use integer types whenever possible.

void displayResult(unsigned long elapsed_MS)
{
  unsigned int h, m, s, ms;
  unsigned long remaining = elapsed_MS;


  ms = remaining % 1000;
  remaining /= 1000;  // Convert to seconds


  s = remaining % 60;
  remaining /= 60; // Convert to minutes


  m = remaining % 60;
  remaining /= 60; // Convert to hours


  h = remaining;


  Serial.print("Elapsed milliseconds: ");
  Serial.println(elapsed_MS);
  Serial.print("Elapsed time: ");
  // Display time as hhh:mm:ss.mmm
  Serial.print(h);
  Serial.print(":");
  // Add a leading zero if needed
  if (m < 10)
    Serial.print('0');
  Serial.print(m);
  Serial.print(":");
  // Add a leading zero if needed
  if (s < 10)
    Serial.print('0');
  Serial.print(s);
  Serial.print(".");
  // Add up to two leading zeroes for milliseconds
  if (ms < 100)
    Serial.print('0');
  if (ms < 10)
    Serial.print('0');
  Serial.print(ms);
  Serial.println();
}

I think the delays are going to be a problem... Your program pauses during delay() so for example, you can't check for a red-light condition or turn-on the red light until after the delays are done and your program gets-around to checking.

Take a look at **Blink Without Delay **and Demonstration code for several things at one time. Or, you might want to use interrupts.

Sometimes it's best to avoid delay() completely or only use very-short delays very-carefully.

BTW - You can only have one main loop, but inside that main loop you can have multiple for-loops, do-loops, or do-while loops (and these can be nested).

thank you everyone for your input i completely rewrote the code to this, is there any advice that anyone can find before i start wiring?

const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte LEDYellow1 = 6;
const byte LEDYellow2 = 8;
const byte LEDYellow3 = 10;
const byte LEDGreen = 11;
const byte LEDRed = 12;

int LEDYellow1Delay = 500;
int LEDYellow2Delay = 500;
int LEDYellow3Delay = 500;

int myLEDs[12];

int PINlaser1 = A0; 
int PINlaser2 = A1; 
int PINlaser3 = A3;

int myLasers[3];

int laserInterruptSensitivity = 10;

int now = 0;

int raceStartTime = 0;
int raceElapsedTime = 0;
int raceFinishTime = 0;

int countdown = 0; 
int countdownDelay = 0;
int countdownStart = 0; 

bool raceHasStarted = false;
bool raceHasFinished = false;

// Checks if sensor 'value' is blocked
void isSensorBlocked(int value) {
   if (value > laserInterruptSensitivity) {
    return true;
  }
  return false;
}

// Turns on Light 'light' and updates MyLEDs array to indicate the light is on
void turnOnLight(int light){
  digitalWrite (light, HIGH);
  myLEDs[light] = true;
}

// Turns off Light 'light' and updates MyLEDs array to indicate the light is off
void turnOffLight(int light){
  digitalWrite (light, LOW);
  myLEDs[light] = false;
}

// Check if race has countdownStarted
bool raceHascountdownStarted(){
  if(myLEDs[LEDGreen] == true) return true;
  return false;
}

// Check if race has ended
bool raceHasEnded(){
  return false;
}

bool countdownInProgress(int now){

  if(countdownStart == 0) return false;
  if(now - countdownStart > countdownDelay){
    countdown = now - countdownStart - countdownDelay;
    return true;
  }
  return false;
  
}

void endCountdown(){

        // turn on Red LED
      turnOnLight(LEDRed);

      // turn off all other LEDs
      turnOffLight(LEDWhite1);
      turnOffLight(LEDWhite2);
      turnOffLight(LEDYellow1);
      turnOffLight(LEDYellow2);
      turnOffLight(LEDYellow3);
}


void setup() {

  Serial.begin(9600);
  
  pinMode(LEDWhite1, OUTPUT); // pre stage white
  pinMode(LEDWhite2, OUTPUT); // stage white
  pinMode(LEDYellow1, OUTPUT); // Yellow one - comes on after first laser is interrupted (but can turn off at any time if they go off the laser)
  pinMode(LEDYellow2, OUTPUT); // Yellow two - comes on after second laser is interrupted (but can turn off at any time if they go off the laser)
  pinMode(LEDYellow3, OUTPUT); // Yellow three - blinks 7 seconds after last LED they a .500 second delay befor next LED
  pinMode(LEDGreen, OUTPUT); // Green -  turn on if they dont move from the laser before LED 5 but after LED 2
  pinMode(LEDRed, OUTPUT); // Red - if they move from the laser before green

  // if analog input pin 0 is unconnected, random analog
  // noise will cause the call to randomSeed() to generate
  // different seed numbers each time the sketch runs.
  // randomSeed() will then shuffle the random function.
  randomSeed(analogRead(0));

  countdownDelay = random(7001);  // generate random integer between 1 and 7000

}


  





void loop() {

  // Get current time
  now = millis();
  
  // Get Laser Values
  int laser1 = analogRead(PINlaser1);
  int laser2 = analogRead(PINlaser2);
  int laser3 = analogRead(PINlaser3);

  // Printout Laser Values
  Serial.print("Analog reading1 = ");
  Serial.print(analogValue1);
  Serial.print("Analog reading2 = ");
  Serial.print(analogValue2);
  Serial.print("Analog reading3 = ");
  Serial.print(analogValue3);

  // race has finished
  if (isSensorBlocked(laser3)) { 
    raceHasFinished = true;
    raceFinishTime = now - raceStartTime;
    Serial.print("Finish time: ");
    Serial.println(raceFinishedTime); 
  }

  // race has started but hasn't finished
  if(raceHasStarted and !raceHasFinished){
    raceElapsedTime = now - raceStartTime;
    Serial.print("Elapsed time: ");
    Serial.println(raceElapsedTime); 
  }
  
  // if laser 1 sensor is blocked turn on white led 1
  if (isSensorBlocked(laser1)) { 
    turnOnLight(LEDWhite1);
  }

  // if laser 2 sensor is blocked turn on white led 2 and countdownStart countdown
  if (isSensorBlocked(laser2)) { 
    turnOnLight(LEDWhite2);
    countdownStart = millis();  // time laser 2 was blocked
  }

  // if the countdown has started but laser 2 is no no longer blocked
  if(!isSensorBlocked(laser2) and countdownStart > 0){

    endCountdown();

  }

  
  if(countdownInProgress(now){

    // Turn on Yellow 1
      turnOnLight(LEDYellow1);
    
    
    // Turn on Yellow 2
    if(countdown > LEDYellow1Delay){
      turnOnLight(LEDYellow2);
    }

    // Turn on Yellow 3
    if(countdown > LEDYellow2Delay){
      turnOnLight(LEDYellow3);
    }

    // Turn on Green
    if(countdown > LEDYellow3Delay){
      turnOnLight(LEDGreen);
      raceHasStarted = true;
      raceStartTime = now;
    }

    
  }
  

}


/*
void displayResult()

{ float h, m, s, ms; unsigned long over; elapsed = finished - countdownStart; h = int(elapsed / 3600000); over = elapsed % 3600000; m = int(over / 60000); over = over % 60000; s = int(over / 1000); ms = over % 1000; Serial.print("Milliseconds so far: "); //The text that will be displayed before the amount of milliseconds passed.

  Serial.println(elapsed); Serial.print("Elapsed time: "); //The text that will be displayed before the amout of time elapsed.

  Serial.print(h, 0); Serial.print("h "); Serial.print(m, 0); Serial.print("m "); Serial.print(s, 0); Serial.print("s "); Serial.print(ms, 0); Serial.println("ms"); Serial.println();
}
*/

I assume You've tested it all using breadboards or similiar. If it does what You want You hit the goal.

  countdownDelay = random(7001);  // generate random integer between 1 and 7000

Wrong. This generates a random integer between 0 and 7000.

I fixed that can you help me with the timers, there should be two one from green light to begining of race for the reaction time and one from the begining to the end of the race did i do it right?

// Pin values for Lights
const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte LEDYellow1 = 6;
const byte LEDYellow2 = 8;
const byte LEDYellow3 = 10;
const byte LEDGreen = 11;
const byte LEDRed = 12;

// Pin values for Lasers
int PINlaser1 = A0;
int PINlaser2 = A1;
int PINlaser3 = A3;

//  Delay between the countdoown lights
int LEDYellow1Delay = 500;  // delay between yellow 1 LED and yellow 2 LED
int LEDYellow2Delay = 500;  // delay between yellow 2 LED and yellow 3 LED
int LEDYellow3Delay = 500;  // delay between yellow 3 LED and green LED

int myLEDs[12]; // array that stores values for whether a given light is on, using the Pin value
int myLasers[3];  // array that stores values for whether a given laser was blocked at start of loop, using the Pin value

int laserInterruptSensitivity = 10; // sensitivity value to determine if sensor is blocked

// Timers for Race
int raceStartTime = 0;
int raceElapsedTime = 0;
int raceFinishTime = 0;

// Timers for Light Countdown
int countdown = 0;
int countdownDelay = 7; // stores amount of time between blocking sensor 2 and starting the countdown
int countdownStart = 0;

int now = 0;  // used to determine the time the loop starts.  This is overwritten with a new time each time the loop runs

bool raceHasStarted = false;
bool raceHasFinished = false;

// Checks if sensor 'value' is blocked
bool isSensorBlocked(int value) {
  if (value > laserInterruptSensitivity) {
    return true;
  }
  return false;
}

// Turns on Light 'light' and updates MyLEDs array to indicate the light is on
void turnOnLight(int light) {
  digitalWrite (light, HIGH);
  myLEDs[light] = true;
}

// Turns off Light 'light' and updates MyLEDs array to indicate the light is off
void turnOffLight(int light) {
  digitalWrite (light, LOW);
  myLEDs[light] = false;
}


bool countdownInProgress(int now) {

  if (countdownStart == 0) return false;
  if (now - countdownStart > countdownDelay) {
    countdown = now - (countdownStart + countdownDelay);
    return true;
  }
  return false;

}

//
// turn on Red LED, turn off all others
void falseStart() {

  // turn on Red LED
  turnOnLight(LEDRed);

  // turn off all other LEDs
  turnOffLight(LEDWhite1);
  turnOffLight(LEDWhite2);
  turnOffLight(LEDYellow1);
  turnOffLight(LEDYellow2);
  turnOffLight(LEDYellow3);
}


void setup() {

  Serial.begin(9600);

  pinMode(LEDWhite1, OUTPUT); // pre stage white - comes on after first laser is interrupted (but can turn off at any time if they go off the laser)
  pinMode(LEDWhite2, OUTPUT); // stage white - comes on after second laser is interrupted (but can turn off at any time if they go off the laser)
  pinMode(LEDYellow1, OUTPUT); // Yellow one - blinks 7 seconds after last LED they a .500 second delay before next LED
  pinMode(LEDYellow2, OUTPUT); // Yellow two
  pinMode(LEDYellow3, OUTPUT); // Yellow three
  pinMode(LEDGreen, OUTPUT); // Green -  turn on if they dont move from the laser before LED 5 but after LED 2
  pinMode(LEDRed, OUTPUT); // Red - if they move from the laser before green




}








void loop() {

  // Get current time
  now = millis();

  // Get Laser Values
  int laser1 = analogRead(PINlaser1);
  int laser2 = analogRead(PINlaser2);
  int laser3 = analogRead(PINlaser3);

  // Printout Laser Values
  Serial.print("Analog reading1 = ");
  Serial.print(laser1);
  Serial.print("Analog reading2 = ");
  Serial.print(laser2);
  Serial.print("Analog reading3 = ");
  Serial.print(laser3);

  /*

     Everything below this line is AFTER race finished

  */
  if (raceHasFinished) {

    // do nothing?

  }

  /*

      Everything below this line is for AFTER race starts

  */

  else if (raceHasStarted and !raceHasFinished) {

    // race has just finished
    if (isSensorBlocked(laser3)) {
      raceHasFinished = true;
      raceFinishTime = now - raceStartTime;  // Time from Green Light to Finish
      Serial.print("Finish time: ");
      Serial.println(raceFinishTime);
    }
    // race is still in progress
    else {
      raceElapsedTime = now - raceStartTime;  // Time from Green Light to Current Time
      Serial.print("Elapsed time: ");
      Serial.println(raceElapsedTime);
    }

  }

  /*

      Everything below this line is BEFORE the RACE starts

  */

  else if (countdownInProgress(now)) {

  // Turn on Green
  if (countdown > LEDYellow1Delay + LEDYellow2Delay + LEDYellow3Delay + countdownStart) {
      turnOnLight(LEDGreen);
      raceHasStarted = true;
      raceStartTime = now;
    }

    // Turn on Yellow 3
    else if (countdown > LEDYellow1Delay + LEDYellow2Delay + countdownStart) {
      turnOnLight(LEDYellow3);
    }

    // Turn on Yellow 2
    else if (countdown > LEDYellow1Delay + countdownStart) {
      turnOnLight(LEDYellow2);
    }

    // Turn on Yellow 1
    else {
      turnOnLight(LEDYellow1);
    }
  }

  /*

     Everything below this line is Pre-Stage or Stage

  */

  else {

    // if laser 1 sensor is blocked turn on white led 1
    if (isSensorBlocked(laser1)) {
      turnOnLight(LEDWhite1);
    }
    else {
      turnOffLight(LEDWhite1);
    }

    // if laser 2 sensor is blocked turn on white led 2 and countdownStart countdown
    if (isSensorBlocked(laser2)) {
      turnOnLight(LEDWhite2);
      countdownStart = millis();  // time laser 2 was blocked
    }
    else {
      turnOffLight(LEDWhite2);
    }

    // if the countdown has started but not finished but laser 2 is no longer blocked
    if (!isSensorBlocked(laser2) and countdownStart > 0) {
      falseStart();
    }

  }


}
// Timers for Race
int raceStartTime = 0;
int raceElapsedTime = 0;
int raceFinishTime = 0;


// Timers for Light Countdown
int countdown = 0;
int countdownDelay = 7; // stores amount of time between blocking sensor 2 and starting the countdown
int countdownStart = 0;


int now = 0;  // used to determine the time the loop starts.  This is overwritten with a new time each time the loop runs

All variables that hold millis() (or micros()) values should be declared 'unsigned long', not 'int'. If you ever switched to micros() for more precise timing you would only be able to time 32 milliseconds with an 'int'. An 'unsigned long' would work up to 71 minutes.

The code looks pretty good. It compiles without errors or warnings so that is good.

The code would be easier to follow if you use meaningful names for your three 'Laser' pins. It appears that one is at the staging line, one at the fault line, and one at the finish line. The numbers don't make clear which is which.

You set but never use the values in "myLEDs" so you can get rid of the array and the two lines where it is used. You never use the myLasers array at all so you can get rid of it.

It is good practice to use an initial capital letter on the names of global variables. That makes it easier to keep track of which variables are global and which are local.

  if (value > laserInterruptSensitivity)
  {
    return true;
  }
  return false;

Since the '>' operator returns a bool, this can be simplified to:

    return value > laserInterruptSensitivity;

If timing is critical, there is no need to read the three 'Laser' value at the start of loop(). You can change the 'isSensorBlocked()' function to take a pin number and read the analog input only when the value is needed. That will speed up loop() a bit.

You were accidentally checking the Starting Line laser for a fault when you should be checking the Staging Line laser.

I'm a little confused about 'countdown' vs ' countdownStart' and the countdownInProgress() function. It seems to have something to do with a very short delay (7 milliseconds) between the car reaching the staging line and the start of the display?

Here is your sketch with the above issues fixed and suggestions applied.

// Pin values for Lights
const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte LEDYellow1 = 6;
const byte LEDYellow2 = 8;
const byte LEDYellow3 = 10;
const byte LEDGreen = 11;
const byte LEDRed = 12;


// Pin values for Lasers
const byte StagingLinePin = A0;
const byte StartingLinePin = A1;
const byte FinishLinePin = A3;


//  Delay between the countdoown lights
const unsigned InitialDelay = 7; // between Start Line and first Yellow
const unsigned YellowDelay = 500;  // between each Yellow and Green


const int LaserInterruptSensitivity = 10; // sensitivity value to determine if sensor is blocked


// State Flags
bool RaceHasStarted = false;  // Set 'true' when Green light is turned on

bool RaceHasFinished = false; // Set 'true' when Finish Line is crossed

// Timers for Race
unsigned long RaceStartTime = 0;  // Set to micros() when Green light is turned on
unsigned long RaceFinishTime = 0;  // Set to micros() when Finish Line is crossed


// Timer for Light Countdown
// Note: Doubles as a state flag: if != 0, countdown is in progress
unsigned long  CountdownStart = 0;  // Set to millis() when Start Line is crossed


// Checks if sensor on analog input 'pin' is blocked
bool isSensorBlocked(byte pin)
{
  return analogRead(pin) > LaserInterruptSensitivity;
}


// Turns on Light on pin 'lightPin'
void turnOnLight(byte lightPin)
{
  digitalWrite (lightPin, HIGH);
}


// Turns off Light on pin 'lightPin'
void turnOffLight(byte lightPin)
{
  digitalWrite (lightPin, LOW);
}

// turn on Red LED, turn off all others
void falseStart()
{
  // turn on Red LED
  turnOnLight(LEDRed);


  // turn off all other LEDs
  turnOffLight(LEDWhite1);
  turnOffLight(LEDWhite2);
  turnOffLight(LEDYellow1);
  turnOffLight(LEDYellow2);
  turnOffLight(LEDYellow3);
  turnOffLight(LEDGreen);

}

void setup()
{
  Serial.begin(9600);


  pinMode(LEDWhite1, OUTPUT); // Pre-stage: Car is on Staging Line
  pinMode(LEDWhite2, OUTPUT); // Staged: Car has reached Start Line
  pinMode(LEDYellow1, OUTPUT); // Turns on 'InitialDelay' milliseconds after White2
  pinMode(LEDYellow2, OUTPUT); // Turns on 'YellowDelay' milliseconds after Yellow1 
  pinMode(LEDYellow3, OUTPUT); // Turns on  'YellowDelay' milliseconds after Yellow2
  pinMode(LEDGreen, OUTPUT); // Start: Turns on  'YellowDelay' milliseconds after Yellow3
  pinMode(LEDRed, OUTPUT); // Fault: Leaving Staging Line between White2 and Green
}


void loop()
{
  // Get current time
  unsigned long now = millis();


  /*
     Everything below this line is AFTER race finished
  */
  if (RaceHasFinished)
  {
    // do nothing?
  }


  /*
      Everything below this line is for AFTER race starts
  */
  else if (RaceHasStarted)
  {
    // The race has not finished but it has started to the
    // race is in progress.  Waiting for car to cross the finish line
    if (isSensorBlocked(FinishLinePin))
    {
      // race has just finished
      RaceFinishTime = micros();  // Time of Finish
      RaceHasFinished = true;
      Serial.print("Finishing time (sec): ");
      Serial.println((RaceFinishTime - RaceStartTime) / 1000000.0, 6);
    }
    else
    {
      // race is still in progress
      Serial.print("Elapsed time (sec): ");
      Serial.println((micros() - RaceStartTime) / 1000000.0, 6);
    }
  }


  /*
      Everything below this line is BEFORE the RACE starts
  */


  else if (CountdownStart != 0) // The contdown to the start is in progress
  {
    // The race has not started or finished but the countdown to start
    // is in progress so we light up the lights in sequence
    
    unsigned long elapsedCountdown = now - CountdownStart;


    // The car has left the Staging Line before the countdown ended!
    if (!isSensorBlocked(StagingLinePin))
    {
      falseStart();


      // DO NOT CONTINUE COUNTDOWN!
      CountdownStart = 0;
      return;
    }


    if (elapsedCountdown >= (InitialDelay))
      turnOnLight(LEDYellow1);


    if (elapsedCountdown >= (InitialDelay + YellowDelay))
      turnOnLight(LEDYellow2);


    if (elapsedCountdown >= (InitialDelay + YellowDelay + YellowDelay))
      turnOnLight(LEDYellow3);


    if (elapsedCountdown >= (InitialDelay + YellowDelay + YellowDelay + YellowDelay))
    {
      // START!
      turnOnLight(LEDGreen);
      RaceHasStarted = true;
      RaceStartTime = micros(); // Measure race in microseconds
      CountdownStart = 0; // Countdown is done
    }
  }
  /*
     Everything below this line is Pre-Stage or Stage
  */
  else
  {
    // The race is not finished or running and the countdown isn't in 
    // progress so we are waiting for pre-staging and staging.


    // White led 1 is ON when Staging Line sensor is blocked
    if (isSensorBlocked(StagingLinePin))
    {
      turnOnLight(LEDWhite1);
    }
    else
    {
      turnOffLight(LEDWhite1);
    }


    // if Starting Line sensor is blocked turn on white led 2 and start countdown
    if (isSensorBlocked(StartingLinePin))
    {
      turnOnLight(LEDWhite2);
      CountdownStart = millis();  // Start the countdown to GREEN
    }
  }
}

I looked over the code thank you! i was wondering is there a way where one arduino can just output a high signal and another recieve that signal as if it was a sensor, without having a master slave to it just have it act as a sensor

Yes. Just connect their GND. One Arduino digital output into the other Arduino digital input.

ignisgraecus: I looked over the code thank you! i was wondering is there a way where one arduino can just output a high signal and another recieve that signal as if it was a sensor, without having a master slave to it just have it act as a sensor

Yes, just connect one Arduino digital output to the other Arduino digital input. But things get complicated if they are running from different power supplies, because an "off" unit can be parasitically powered from a digital input connected to an active output on another unit that is HIGH.