Drag Tree

like this ?

Yes! Bingo!
Remember that the controller input at all times must have a connection. When the switch is activated it gets 5 volt. As soon as the switch starts to move there will be glitches, a serie of Ons and Offs. That's called bouncing and is unavoidable. Software might be needed to take care of that, but not always.
The important thing is that during the Off switch state the controller input reads a well defined voltage level, in this case GND, made by the pull down resistor.

Thank you so much now that i have the wiring down, whenever i try to run my code it detects the switches but the timer wont start and the LED's wont turn on

Hopefully the hardware is in order.
Now we need to deal with the software.
A very helpful way is to use Serial.print and Serial Monitor in the IDE to print out values from inside the code. That helped me to crack large, unknown systems during many years.
Can You post the last code again? Writing this reply I can't step back for the code.

this is my last code, i tried doing serial prints and where the led turns on it wont print either

// Pin values for Lights
const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte ARDUINOoutput = 3;
const byte ARDUINOInput = 5;
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 = 7;
const byte StartingLinePin = 9;
const byte FinishLinePin = 13;


//  Delay between the countdoown lights
const unsigned InitialDelay = 7000; // between Stage and first Yellow
const unsigned YellowDelay = 500;  // between each Yellow and Green


const int LaserInterruptSensitivity = 0ity 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 ReactionTime = 0;   // Set to micros() when car finishes going past start line
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
bool isSensorBlocked(byte pin)
{
  return (digitalRead(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(StagingLinePin, INPUT); //staging line blocked
  pinMode(StartingLinePin, INPUT); // starting line pin
  pinMode(FinishLinePin, INPUT); // finish line pin
  pinMode(ARDUINOoutput, OUTPUT);  // Arduino sends out signal to other arduino saying car is staged
  pinMode(ARDUINOInput, INPUT);   // Arduino recieves signal from other arduino saying car is staged
  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 RestartRace() {

  CountdownStart = 0;
  RaceHasStarted = false;
  RaceHasFinished = false;
  RaceStartTime = 0;
  ReactionTime = 0;
  RaceFinishTime = 0;
  turnOffLight(LEDRed);
  turnOffLight(LEDWhite1);
  turnOffLight(LEDWhite2);
  turnOffLight(LEDYellow1);
  turnOffLight(LEDYellow2);
  turnOffLight(LEDYellow3);
  turnOffLight(LEDGreen);
}

void loop()
{
  // Get current time
  unsigned long now = millis();
  //                Serial.println("millis");

  //    Serial.print(analogRead(StagingLinePin)); Serial.print("   ");Serial.println(LaserInterruptSensitivity);

  /*
     Everything below this line is AFTER race finished
  */
  if (RaceHasFinished)
  { delay(10000);
    RestartRace();
    //restart program
  }


  /*
      Everything below this line is for AFTER race starts
  */
  else if (RaceHasStarted)
  {
    Serial.println("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))
    {
      Serial.println("RaceFinished");

      // 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("Reaction 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 Starting Line before the countdown ended!
    if (!isSensorBlocked(StartingLinePin))
    {
      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.


    while (digitalRead(StagingLinePin) > LaserInterruptSensitivity) {//waiting for Stage laser to be blocked
      Serial.println(" staging ");
    }
    // White led 1 is ON when Staging Line sensor is blocked

    if (isSensorBlocked(StagingLinePin))
    {
      turnOnLight(LEDWhite1);
     

    }
    else
    {
      turnOffLight(LEDWhite1);
    }

    while (digitalRead(StartingLinePin) > LaserInterruptSensitivity) {//waiting for Start laser to be blocked
      Serial.println(" starting ");
    }
    // if Starting Line sensor is blocked turn on white led 2 and check other arduino for car stage
    if (isSensorBlocked(StartingLinePin))

    {
      turnOnLight(LEDWhite2);
      digitalWrite (ARDUINOoutput, HIGH);
    }
    //    while (digitalRead(ARDUINOInput) == LOW) { //waiting for high signal from other arduino
    //    }
  }
  if (isSensorBlocked(StartingLinePin) && (CountdownStart == 0) ) // && digitalRead(ARDUINOInput) == HIGH)
  {
    CountdownStart = millis();  // Start the countdown to GREEN
    Serial.print(" Countdown "); Serial.println(digitalRead(ARDUINOInput));
  }

}

That code does not even compile. That is not the code You are running.

First suspect:

const int LaserInterruptSensitivity = 0ity value to determine if sensor is blocked

Correct that line.

Next:   return (digitalRead(pin) < LaserInterruptSensitivity);
Digital read either yields 0 or 1. It can never be less than 0.

Hi,
Have you written simple code to verify that your hardware is working and that Serial.print is working?

Lets get back to basics....

Tom.... :slight_smile:

Railroader, im sorry I pasted the wrong code before I did have those fixed I noticed those mistakes before here is the actual code

// Pin values for Lights
const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte ARDUINOoutput = 3;
const byte ARDUINOInput = 5;
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 = 7;
const byte StartingLinePin = 9;
const byte FinishLinePin = 13;


//  Delay between the countdoown lights
const unsigned InitialDelay = 7000; // between Stage and first Yellow
const unsigned YellowDelay = 500;  // between each Yellow and Green


const int LaserInterruptSensitivity = 0; // 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 ReactionTime = 0;   // Set to micros() when car finishes going past start line
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
bool isSensorBlocked(byte pin)
{
  return (digitalRead(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(StagingLinePin, INPUT); //staging line blocked
  pinMode(StartingLinePin, INPUT); // starting line pin
  pinMode(FinishLinePin, INPUT); // finish line pin
  pinMode(ARDUINOoutput, OUTPUT);  // Arduino sends out signal to other arduino saying car is staged
  pinMode(ARDUINOInput, INPUT);   // Arduino recieves signal from other arduino saying car is staged
  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 RestartRace() {

  CountdownStart = 0;
  RaceHasStarted = false;
  RaceHasFinished = false;
  RaceStartTime = 0;
  ReactionTime = 0;
  RaceFinishTime = 0;
  turnOffLight(LEDRed);
  turnOffLight(LEDWhite1);
  turnOffLight(LEDWhite2);
  turnOffLight(LEDYellow1);
  turnOffLight(LEDYellow2);
  turnOffLight(LEDYellow3);
  turnOffLight(LEDGreen);
}

void loop()
{
  // Get current time
  unsigned long now = millis();
  //                Serial.println("millis");

  //    Serial.print(analogRead(StagingLinePin)); Serial.print("   ");Serial.println(LaserInterruptSensitivity);

  /*
     Everything below this line is AFTER race finished
  */
  if (RaceHasFinished)
  { delay(10000);
    RestartRace();
    //restart program
  }


  /*
      Everything below this line is for AFTER race starts
  */
  else if (RaceHasStarted)
  {
    Serial.println("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))
    {
      Serial.println("RaceFinished");

      // 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("Reaction 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 Starting Line before the countdown ended!
    if (!isSensorBlocked(StartingLinePin))
    {
      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.


    while (digitalRead(StagingLinePin) > LaserInterruptSensitivity) {//waiting for Stage laser to be blocked
      Serial.println(" staging ");
    }
    // White led 1 is ON when Staging Line sensor is blocked

    if (isSensorBlocked(StagingLinePin))
    {
      turnOnLight(LEDWhite1);

    }
    else
    {
      turnOffLight(LEDWhite1);
    }

    while (digitalRead(StartingLinePin) > LaserInterruptSensitivity) {//waiting for Start laser to be blocked
      Serial.println(" starting ");
    }
    // if Starting Line sensor is blocked turn on white led 2 and check other arduino for car stage
    if (isSensorBlocked(StartingLinePin))

    {
      turnOnLight(LEDWhite2);
      digitalWrite (ARDUINOoutput, HIGH);
    }
    //    while (digitalRead(ARDUINOInput) == LOW) { //waiting for high signal from other arduino
    //    }
  }
  if (isSensorBlocked(StartingLinePin) && (CountdownStart == 0) ) // && digitalRead(ARDUINOInput) == HIGH)
  {
    CountdownStart = millis();  // Start the countdown to GREEN
    Serial.print(" Countdown "); Serial.println(digitalRead(ARDUINOInput));
  }

}

Tom, I did check every piece of hardware i checked the LED's with blink and even the switches to start the blink code, it even printed

That's good.
What is the status of a test run? What happens and what doesn't happen? What status prints do You get?

 const int LaserInterruptSensitivity = 0;
...
return (digitalRead(pin) > LaserInterruptSensitivity);

This is ... unusual.

Your last reply, told in the notifying Email, is missing here.

Don't expand the project before it runs well.

I finished the code, my final question is one sensor has to be a quarter mile away is there any way to achieve this?

/*
  _________                         __                 __
  \_   ___ \  ____   ____   _______/  |______    _____/  |_  ______
  /    \  \/ /  _ \ /    \ /  ___/\   __\__  \  /    \   __\/  ___/
  \     \___(  <_> )   |  \\___ \  |  |  / __ \|   |  \  |  \___ \
  \______  /\____/|___|  /____  > |__| (____  /___|  /__| /____  >
        \/            \/     \/            \/     \/          \/
*/

// Pin values for Lights
const byte LEDWhite1 = 2;
const byte LEDWhite2 = 4;
const byte ARDUINOoutput = 3;
const byte ARDUINOInput = 5;
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 = 7;
const byte StartingLinePin = 9;
const byte FinishLinePin = 13;

//  Delay between the countdoown lights
const unsigned InitialDelay = 1000; // between Stage and first Yellow
const unsigned YellowDelay = 500;  // between each Yellow and Green
//const unsigned DebugDelay = 1000;  // between each Yellow and Green

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

/*
  ____   ____            .__      ___.   .__
  \   \ /   /____ _______|__|____ \_ |__ |  |   ____   ______
  \   Y   /\__  \\_  __ \  \__  \ | __ \|  | _/ __ \ /  ___/
  \     /  / __ \|  | \/  |/ __ \| \_\ \  |_\  ___/ \___ \
   \___/  (____  /__|  |__(____  /___  /____/\___  >____  >
               \/              \/    \/          \/     \/
*/

// 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
unsigned long ReactionTimer = 0; // This will contain the reaction time

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

// Time since start of program
unsigned long now;

/*
  ___________                   __  .__
  \_   _____/_ __  ____   _____/  |_|__| ____   ____   ______
  |    __)|  |  \/    \_/ ___\   __\  |/  _ \ /    \ /  ___/
  |     \ |  |  /   |  \  \___|  | |  (  <_> )   |  \\___ \
  \___  / |____/|___|  /\___  >__| |__|\____/|___|  /____  >
     \/             \/     \/                    \/     \/
*/

// Checks if sensor on analog input 'pin' is blocked
bool isSensorBlocked(byte pin)
{

  int val = 0;
  val = digitalRead(pin);  // read input value
  //Serial.print("Sensor Value: ");
  //Serial.print(val);
  //Serial.print("\n");

  return digitalRead(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 checkStagingPin() {

  if (isSensorBlocked(StagingLinePin)) {
    //Serial.print("Staging Pin is blocked\n");
    turnOnLight(LEDWhite1);
    // delay(DebugDelay);
  }
  else {
    //Serial.print("Staging Pin NOT blocked\n");
    turnOffLight(LEDWhite1);
    // delay(DebugDelay);
  }

}

// if Starting Line sensor is blocked turn on white led 2 and check other arduino for car stage
void checkStartingPin() {

  if (isSensorBlocked(StartingLinePin)) {
    //Serial.print("Start Pin is blocked  on THIS Arduino \n");
    // Turn off the red light again. We are back at the start.
    turnOffLight(LEDRed);
    turnOnLight(LEDWhite2);
    digitalWrite (ARDUINOoutput, HIGH);
    // delay(DebugDelay);
  } else { // 
    digitalWrite(ARDUINOoutput, LOW);
    turnOffLight(LEDWhite2);
  }

  if ((digitalRead(ARDUINOInput) == HIGH) && isSensorBlocked(StartingLinePin)) { 
    //Serial.print("Start Pin is blocked on OTHER Arduino \n");
    CountdownStart = millis();  // Start the countdown to GREEN
  } 
}

void RaceInPreStage() {
  //Serial.print("Pre-Stage\n");
  checkStagingPin();
  checkStartingPin();
}

void RaceInCountdown() {

  //Serial.print("Now: ");
  //Serial.print(now);
  //Serial.print(" CountdownStart: ");
  //Serial.println(CountdownStart);

  unsigned long elapsedCountdown =  now - CountdownStart;

  checkStagingPin();

  // The car has left the Starting Line before the countdown ended!
  if (!isSensorBlocked(StartingLinePin)) {
    falseStart();
    CountdownStart = 0; // DO NOT CONTINUE COUNTDOWN!
    return;
  }

  //Serial.println(elapsedCountdown);
  //Serial.println(InitialDelay);
  //Serial.println(InitialDelay + YellowDelay);

  if (elapsedCountdown >= (InitialDelay)) {
    //Serial.print("We get here.");
    turnOnLight(LEDYellow1);
  }

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

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

  if (elapsedCountdown >= (InitialDelay + YellowDelay + YellowDelay + YellowDelay)) {
    // START!
    turnOnLight(LEDGreen);
    turnOffLight(LEDWhite1);
    turnOffLight(LEDWhite2);
    turnOffLight(LEDYellow1);
    turnOffLight(LEDYellow2);
    turnOffLight(LEDYellow3);
    RaceHasStarted = true;
    RaceStartTime = micros(); // Measure race in microseconds
    CountdownStart = 0; // Countdown is done
  }
}

void RaceInProgress() {

  //Serial.print("Race has started");


  // When the car leaves the starting line after we turned green, capture the reaction time
  if ( ReactionTimer == 0 && !isSensorBlocked(StartingLinePin)) {
    //turnOffLight(LEDWhite1);
    //turnOffLight(LEDWhite2);
    //turnOffLight(LEDYellow1);
    //turnOffLight(LEDYellow2);
    //turnOffLight(LEDYellow3);

    ReactionTimer = micros() - RaceStartTime;
    Serial.print("Reaction Time (sec): ");
    Serial.println(ReactionTimer / 1000000.0, 6);
  }

  // Car has crossed Finish Line
  if (isSensorBlocked(FinishLinePin)) {
    RaceFinishTime = micros();  // Time of Finish
    RaceHasFinished = true;
    Serial.print("Finishing time (sec): ");
    Serial.println((RaceFinishTime - RaceStartTime) / 1000000.0, 6);
  }

  // Car has NOT crossed finish line
  // else {
  //   race is still in progress
  ////   Serial.print("Reaction Time (sec): ");
  ////   Seriprintln((micros() - RaceStartTime) / 1000000.0, 6);
  // }

}

void RaceDone() {
  while (1);
}


/*
    _____            .___    .__
  /  _  \_______  __| _/_ __|__| ____   ____
  /  /_\  \_  __ \/ __ |  |  \  |/    \ /  _ \
  /    |    \  | \/ /_/ |  |  /  |   |  (  <_> )
  \____|__  /__|  \____ |____/|__|___|  /\____/
        \/           \/             \/

*/

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

  // Initialize Lights On Drag Tree
  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

  // Initialize Input Lasers
  pinMode(StagingLinePin, INPUT); //checks stage light laser
  pinMode(StartingLinePin, INPUT); //checks stage light laser
  pinMode(FinishLinePin, INPUT); //checks finish line light laser

  // Initialize communications between the two arduinos
  pinMode(ARDUINOoutput, OUTPUT);  // Arduino sends out signal to other arduino saying car is staged
  pinMode(ARDUINOInput, INPUT);   // Arduino recieves signal from other arduino saying car is staged
}


void loop()
{
  // digitalWrite (LEDWhite1, HIGH);
  now = millis(); // Get current time

  if (RaceHasFinished) {
    RaceDone();
  }
  else if (RaceHasStarted) {
    RaceInProgress();
  }
  else if (CountdownStart != 0) {
    RaceInCountdown();
  }
  else {
    RaceInPreStage();
  }


}

Read reply #50.....

int val = 0;
  val = digitalRead(pin);  // read input value

I truly do not understand this programming idiom.
Let's hope the compiler is smart enough to ignore it.

I accidentally hit post on an old code and had to erase it, that is why it showed im sorry my question is is there a way to put a sensor 1/4 mile away, AWOL the code is running great already i have to build everything now

Sure, make the sensor wireless. Send it a message that the lights are turned green, let it do the timing, and send the results back. How long do you think it takes a message going the speed of light to go a quarter mile?

"In miles per hour, light speed is, well, a lot: about 670,616,629 mph"

So, hour/miles x 0.25 miles = time to go 1/4 mile = T x 60min/hour x 60 sec/min x 1000000000nS/Sec = 1342nS, or 21 clocks at 16 MHz.

These have 1000 meter range (>1/2 mile) at a "slow" data rate (> twice that of an Arduino running serial at 115200)
so I would think with good antennas should handle a start signal and return of a time and/or speed some number of seconds later.

http://www.yourduino.com/sunshop/index.php?l=product_detail&p=191
And this for reliable sending
http://www.yourduino.com/sunshop/index.php?l=product_detail&p=467

Or get all 3 as a "kit" and save $9

Other wireless options exist.
Or, run 1/4 mile of wire and use RS485
https://www.analog.com/media/en/technical-documentation/product-selector-card/rs485fe.pdf

Wire will be $1275 (USD) with 1000, 1000, and 500 ft spools needed at $0.47/ft.
https://www.automationdirect.com/adc/overview/catalog/wiring_solutions/bulk_multi-conductor_cable/rs-485_-a-_rs-422-z-rs-232_cable_(bulk)
https://www.automationdirect.com/adc/shopping/catalog/cables/bulk_multi-conductor_cable/rs-485_-a-_rs-422-z-rs-232_cable_(bulk)/l19827-1

I'd try a $24 experiment first!

Problem with wireless, is latency. I think there would be at least a few millisecond delay in packet transmission.

Depends on how much is sent. That could be subtracted out if one could figure out how to measure it.

How would i program the wireless one ?

CrossRoads:
Depends on how much is sent. That could be subtracted out if one could figure out how to measure it.

You can have the remote unit echo a packet, then divide the trip time by 2, to get pretty close.