Reading digital sensor goes wrong

I'm trying to read a IR phototransistor. I'm using digital reading, via 4. The white LED which should go on is at pin 11. Another IR LED is just on continuously.

The IR phototransistor is connected via a 10K resistor, at the sensor (so +) side.

When I point the IR LED at the IR sensor, the output is 0 (like expected). But when disabled the led or block the beam, the output is like this:

1
1
1
1
1
1
0
0
0
0
0
0
0

It should be continously be 1, because i block the beam. What do I do wrong?

My code:

#define LED 11
#define BEAM 4

byte i;
void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(BEAM,INPUT);
  digitalWrite(LED,LOW);
  Serial.begin(9600);

}
void loop()
{

  digitalWrite(LED,digitalRead(BEAM));
  Serial.println(digitalRead(BEAM));
  delay(100);
}

Can you get rid of your LED on pin 11? I don't see a current-limiting resistor with that LED BTW. Maybe its too bright, emitting enough IR to trigger your phototransistor. Make it simple, one IR LED, one phototransistor. I don't see why you have to have that other LED.

Considering the extremely high impedence of an arduino input pin the voltage downstream of a phototransistor wired open ended through a resistor is going to be very hit and miss. It should be wired similar to this :

The test point being the arduino input.

I totally mentally-swapped the LED and the phototransistor! You're right pluggy. His phototransistor needs the 5V and resistor.