Problem reading analog values

Hello i been trying to make a wireless communication with ir, the only problem is that the value it gets from the ir receiver is pretty much wrong.

i have putting up two sketch, the one only reading values are getting around 900 when the ir led is on and my one is getting only around 180 even if the led is on or off;S?????

mottagare.ino (2.25 KB)

sketch_apr30b.ino (147 Bytes)

Normally IR communication does not use analog input which is slow.
What are you trying to achieve?
You can use well proven solutions involving the PNA4602 and similar IR receivers.

For example I have good results with these:
A Multi-Protocol Infrared Remote Library for the Arduino (Ken Shirriff)
GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols
Overview | IR Sensor | Adafruit Learning System
Mini Remote Control : ID 389 : $4.95 : Adafruit Industries, Unique & fun DIY electronics and kits (mini remote control)

I'm trying to make a communication that allows streaming files on on wireless IR.

I have done BMC coding, (Bi phase mark coding), the sketch was for the receiver part,

I actualy fixed the issue and the next issue is converting the bits i get to into a single byte variable( dont know how to decribe the issue)
Let's say iam sending a 8 bits , 1111 1111 and when iam receving the bits how do i make it into a byte?
ex
byte x= b0000 0000;
byte x= x+bits_rec[z]; z is between 0 and 7
is this possible?

Thanks for the reference to Manchester encoding. I used it many years ago but had forgotten.

Combining bits is no problem. Bit operations are built in to the C language. Arduino is just a thin layer on top and supports the bit shift operators << and >>.

This tutorial should help:
http://playground.arduino.cc/Code/BitMath