Control a servo with a ir sensor (digitalRead)

can some one give the code for controlling a servo motor with ir sensor with digital read. I mean when the ir sensor reads as "HIGH" servo angle should move from 0 to 90 and when the ir sensor reads LOW the servo should be back to 0.

This is the code i have done.

#include<Servo.h>
Servo myservo;
int ir=5;
int val;

void setup() {
myservo.attach(7);
pinMode(ir,INPUT);
pinMode(val,OUTPUT);
Serial.begin(9600);
// put your setup code here, to run once:

}

void loop() {
val = digitalRead(ir);
if(ir==HIGH)
{
myservo.write(50);
}
else
{
myservo.write(120);
}

}

ir has the value 5.
HIGH has the value 1.

They will never be equal.

Please don't hijack unrelated threads.

Please remember to use code tags when posting code

Why do a digitalRead() and then not use the result for anything?

Steve