help with programming photovore if statment

@ jediryan123

photo resistors being within say 100 units of each other

Maybe test the absolute value of the difference with something like

unsigned threshold = 100; // How close they have to be to be considered "nearly equal"
.
.
.
void loop()
{
.
.
.
    if(abs(analogValueR - analogValueL) < threshold) // They are nearly equal
    {
        // Whatever you need to do if they are "nearly equal"
    }

    else // They are not nearly equal
    {
        if(analogValueL < analogValueR)
        {
            //Whatever you do if they are not "nearly equal" and L < R
        }
        else
        {
            //Whatever you do if they are not "nearly equal" and R > L               
        }
    }
.
.
.
}

By making the "threshold" a variable (and not buried inside the logic in the conditional statement), it's easy to see how to experiment with different thresholds by simply changing that declaration to make it equal to some other value.

Regards,

Dave