IR sensor returning opposite values

Hardware:
Arduino UNO
Electronicspices IR proximity sensor (bought from amazon)

Problem:
The sensor detects the object in front of it perfectly (the light on it glows when it encounters another object and vice versa), however the output that i recieve is the very opposite. So when an object is placed in front (both lights glow), it returns false and when no object is in front(only 1 light glows), it returns true, hence i keep getting the opposite results if i ever connect it to the breadboard. Any suggestions of how do i fix this?

Connections:
ground of sensor to ground of arduino
vcc to 5v/Vin
out to digital3

i'm not sure if it helps but here is the small code:

int led = 13;
int ir = 3;
void setup()
{
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(ir, INPUT);
}
void loop()
{
  if(digitalRead(ir)==HIGH)      //Check the sensor output
  {
    digitalWrite(led, HIGH);   // set the LED on
  }
  else
  {
    digitalWrite(led, LOW);    // set the LED off
  }
  Serial.println(digitalRead(ir));
  delay(1000);
}

Just reverse the logic when you read the sensor.

Paul

@Paul_KD7HB, yea that would work however in my final product i plan to do it by directly soldering the components without the arduino board. i was just using the board right now for learning and testing purposes.
also it might be worth mentioning, that when I add a transistor to the setup and use the output from the IR sensor as the base input of transistor it works perfectly (the final out from emitter is the way it should be). any idea as to what might be making that happen?

P.S. im making an automatic hand sanitizer (even the one on youtube has a transistor attached however i plan to add an IC to it to make the time delay better instead of using an entire arduino board as that would be unnecessarily expensive for my case)

Look at how a transistor works. The input signal is ALWAYS inverted on output.

Paul

oh, im sorry my bad. i couldnt find that mentioned anywhere on what i read. thank you for your help