IR sensors not working independently.

I now tried making a line follower robot. Both IR sensors show the same result when they should not! I have one on white paper while the other over black tape, but they both show high. Can someone please help me out on this?
Here is my code:

const int righto = 7;
const int lefto = 8;
const int motor_rightFront = 2;
const int motor_rightBack = 3;
const int motor_leftFront = 4;
const int motor_leftBack = 5;
int x;
int y;
void setup() {
  // put your setup code here, to run once:
for(x = 2; x<6; x++){
  pinMode(x, OUTPUT);
}
for(y=7; y<9 ; y++){
  pinMode(y, INPUT);
}
}

void loop() {
  // put your main code here, to run repeatedly:
int right_sensor = digitalRead(righto);
int left_sensor = digitalRead(lefto);
if(right_sensor == HIGH && left_sensor == LOW){
  left();
}
if(right_sensor == LOW && left_sensor == HIGH){
  right();
}
if(right_sensor == LOW && left_sensor == LOW){
  yay();
}
if(right_sensor == HIGH && left_sensor == HIGH){
  forward();
}
}
void right(){
  digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, LOW);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, HIGH);
}
void left(){
  digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, HIGH);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, LOW);
}
void forward(){
   digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, HIGH);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, HIGH);
}
void yay(){              //This is to make it stop.
   digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, LOW);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, LOW);
}

Both the black and the white paper reflect IR.
Use a daylight detecting sensor.

I do not have a daylight detecting sensor though. I thought that IR sensors should read LOW while on black and HIGH while on white.
I am new to arduino, so can you please explain further?

Black to your eye is not necessarily black to IR. I had the same problem with an encoder disc that I made using a photo copier. It turned out that the copier toner was reflective to IR. I went over the toner with a black Sharpie pen and that worked.

MukeshArvindh:
I do not have a daylight detecting sensor though. I thought that IR sensors should read LOW while on black and HIGH while on white.
I am new to arduino, so can you please explain further?

Thinking is always good but knowing is better. Unless @groundFungus tip gives You a solution You are just banging Your head into the wall, and the wall is the Winner.

Yes. Thank you for the answer. However, one of the IR sensors is able to detect it as black. Only the other one is not.

Check up reply #3.

MukeshArvindh:
Yes. Thank you for the answer. However, one of the IR sensors is able to detect it as black. Only the other one is not.

Could mean one is working and the other is not. Or the sensor may not be identical devices.

Paul

So, what can I do to fix this?

Also,
Now this IR sensor does not work at all unless the other is also on. I have no clue what is going on.

I do understand that the black might not be black enough for IR, but this IR does not work properly unless the other is on, and it shows readings it should not show when the other is on. It even shows LOW on a completely white piece of paper!

I would say that it is time that you post a schematic and the code. I don't see how we can help without that information.

const int righto = 7;
const int lefto = 8;
const int motor_rightFront = 2;
const int motor_rightBack = 3;
const int motor_leftFront = 4;
const int motor_leftBack = 5;
int x;
int y;
void setup() {
  // put your setup code here, to run once:
for(x = 2; x<6; x++){
  pinMode(x, OUTPUT);
}
for(y=7; y<9 ; y++){
  pinMode(y, INPUT);
}
}

void loop() {
  // put your main code here, to run repeatedly:
int right_sensor = digitalRead(righto);
int left_sensor = digitalRead(lefto);
if(right_sensor == HIGH && left_sensor == LOW){
  left();
}
if(right_sensor == LOW && left_sensor == HIGH){
  right();
}
if(right_sensor == LOW && left_sensor == LOW){
  yay();
}
if(right_sensor == HIGH && left_sensor == HIGH){
  forward();
}
}
void right(){
  digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, LOW);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, HIGH);
}
void left(){
  digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, HIGH);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, LOW);
}
void forward(){
   digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, HIGH);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, HIGH);
}
void yay(){              //This is to make it stop.
   digitalWrite(motor_rightFront, LOW);
  digitalWrite(motor_rightBack, LOW);
  digitalWrite(motor_leftFront, LOW);
  digitalWrite(motor_leftBack, LOW);
}

Here is my code.

Grounds for the two LEDs are connected together, but not to the common rail.

There is also a preset on the IR sensors, and I am doubting if probably it is due to this preset that it is reading incorrectly. However, in whatever way I adjust it, it still does not read accurately.

O.k. it's time you told us exactly what "IR sensors" you are talking about. A link to a datasheet would be best. And where is the schematic/circuit diagram you were asked for?

Steve