Problem with IF statements for IR line follower

I’m having trouble with two if statements in my code. My project is basically a mega-line crawler which drives around the track and is made from an RC car and Arduino sensors. The RC car follows the lines on the track through 3 IR sensors. It seems to be working pretty well, but the code doesn’t fully work. I’ve programmed it to turn left when the right-most IR sensor turns goes from LOW to HIGH (that is stops receiving IR light bounced off the white track line) and turn even farther left if the two sensors on the right turn to HIGH. This is also set up for the opposite (turning right when the left sensor is HIGH) But, for some reason the second statement, that should turn the wheels farther if the car is farther off the line (if two IR sensors turn to HIGH), doesn’t work for either turning right or left. That is, the if statement doesn’t trip. The 1st and 2nd if statements are very similar, so I can’t figure out why it doesn’t work.

#include <Servo.h>

// DON’T TOUCH THIS:
Servo sspeed;
Servo ssteer;
int GND = 5;
int PWR = 6;
int SIG = 7;
int GND2 = 11;
int PWR2 = 12;
int SIG2 = 13;
int IR1 = 2;
int IR2 = 3;
int IR3 = 4;

//TOUCH THIS
int carspeed = 80; //SPEED of the car
int angle = 96; //INITIAL ANGLE of steering, 96 appears to be straight

//DON’T TOUCH SETUP
void setup() {
pinMode(GND, OUTPUT);
pinMode(PWR, OUTPUT);
pinMode(GND2, OUTPUT);
pinMode(PWR2, OUTPUT);
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
pinMode(IR3, INPUT);
sspeed.attach(SIG2); //Attach the servo to pin SIG
ssteer.attach(SIG);
sspeed.write(carspeed); //write starting throttle position
ssteer.write(angle);
Serial.begin(9600);

}

void loop() {
//DON’t TOUCH THIS
digitalWrite(PWR, HIGH); // V+ for the header
digitalWrite(GND, LOW); //GND for the header
digitalWrite(PWR2, HIGH); // V+ for the header
digitalWrite(GND2, LOW); //GND for the header
sspeed.write(carspeed);
ssteer.write(angle);

// TOUCH THIS - ONLY ADJUST the numbers after angle -/+=
if (0 == digitalRead(IR1) == digitalRead(IR2) == digitalRead(IR3)) // ON TRACK? GO STRAIGHT
{
angle = angle;
ssteer.write(angle);
}
else if (1 == digitalRead(IR1) and 0 == digitalRead(IR2) and 0 == digitalRead(IR3)) // TURN LEFT
{
angle -=4;
ssteer.write(angle);
}
else if (1 == digitalRead(IR1) and 1 == digitalRead(IR2) and 0 == digitalRead(IR3)) // DOES NOT WORK - NEVER trips (Steering never adjusts by 7)
{
angle -=7;
ssteer.write(angle);
}
else if (1 == digitalRead(IR3) and 1 == digitalRead(IR1) and 1 == digitalRead(IR2)) //IF OFF LINE,STOP
{
angle = angle;
sspeed.write(angle);
}
else if (0 == digitalRead(IR1) and 0 == digitalRead(IR2) and 1 == digitalRead(IR3)) //TURN RIGHT
{
angle +=4;
ssteer.write(angle);
}
else if (0 == digitalRead(IR1) and 1 == digitalRead(IR2) and 1 == digitalRead(IR3)) // DOES NOT WORK - NEVER trips (Steering never adjusts by 7)
{
angle +=7;
ssteer.write(angle);
}
else // CONFUSED? GO STRAIGHT and STOP
{
ssteer.write(angle);
}

delay(100);

}

 if (0 == digitalRead(IR1) == digitalRead(IR2) == digitalRead(IR3))

No, no, no. This won't work the way you think it does. The second digitalRead isn't compared against 0, it's compared against the result of the first comparison.

So if IR1 is LOW then the first is true, so you compare the second read against HIGH. Then if IR2 is HIGH you compare IR3 against HIGH but if IR2 is LOW you compare IR3 against LOW. Or, I think, NO, JUST NO. This is confusing as hell. It shouldn't take this long to ferret out what a line of code will do.

What do you want that line to do?

To see if all three are LOW you would:

if(digitalRead(IR1) == LOW && digitalRead(IR2) == LOW && digitalRead(IR3) == LOW)
else if (0 == digitalRead(IR1) and 1 == digitalRead(IR2) and 1 == digitalRead(IR3)) // DOES NOT WORK  - NEVER trips

It will never get to that line because if those are the conditions then the first if statement is true.

Here’s that one again:

if (0 == digitalRead(IR1) == digitalRead(IR2) == digitalRead(IR3))

If IR1 is LOW then 0 == digitalRead(IR1) is true, So we compare 1 against digitalRead(IR2). So If IR2 is HIGH then we compare IR3 against 1. If it is HIGH then we have a true and this if is the one being tripped.