Speed Calculator Project

niema045:
I could tell where the vehicle is coming from (i.e which direction), the speed, and vehicles/min

Will the above code do this?

No, I don't think so.

I think you want to detect the initial rising edge for each input, and record the time it happens, and then when you have seen both rising edges compare the two times to work out direction and speed. Then wait for long enough for both inputs to settle, and finally go back to the idle state where you're looking for the next rising edge. It could look roughly like this:

// incomplete, uncompiled

int leftValue = analogRead(leftSensorPin);
if((leftTime == 0) and ((leftValue < 400) or (leftValue > 600)))
{
   // left pulse detected
    leftTime = millis();
}
if((rightTime == 0) and (digitalRead(rightSensorPin) == HIGH))
{
    // right pulse detected
    rightTime = millis();
}
if((leftTime > 0) and (rightTime > 0))
{
    // both signals detected, determine direction and speed
    speed = distance / (rightTime - leftTime); //positive speed means left-to-right, negative means right-to-left
    count++; // I don't know whether you want to count each direction separately

    delay(500); // wait long enough for both sensors to settle down
    leftTime = 0;
    rightTime = 0;
}