You connect 5V to the the Collector side of the phototransistor and the Emitter side to the Arduino input pin. Connect a 1k load resistor between the same Arduino input pin and Ground.
You have got 2 things going on here and you need to do them separately:
On one side you have what is a LED and you need to wire it up in series with a resistor. The specs on the sheet say that the Forward Current (If) is 20mA, for Forward Voltage (Vf) of 1.2V. If you are running off a 5V Arduino, you will need to drop 3.8V across the resistor at 20mA. Using Ohms Law (V=I*R) it gives us a resistor of 3.8/.020 = 190 Ohm. Use something close but over this value without being excessively over.
One the output side you have what is a voltage divider. If Vcc is 5V then I would try something like a 1k resistor.
The wiring diagram, by the way, is bottom left of page 2 of the specsheet.
Thank you all for your help !! but the readings I get are all zeros.
this is the circuit:
Emitter: I connected 5v in series with a resistor(190 ohm) to the (+) pin, and the (-) to the gnd.
Receiver: I connected 5v directly to the (+) pin, and the (-) to the analog input and to gnd with (1k ohm) resistor.
I've noticed that when I connect the output to pin A0 I get Zeros, but when I disconnect it I get values around 1000 !!!
If that would help somehow !!!
I'm sorry but it's my first project with Arduino, and I'm new to these stuff
int val0=0;
int irPin0 = A0; // <- this needs to be the pin you want to read from
void setup()
{
Serial.begin(9600);
}
void loop()
{
val0 = analogRead(irPin0);
Serial.print(val0);
Serial.print("\n\r");
delay(1500);
}
Ok, it seems to work on my setup with a Pot on A0, but I have no idea why. A0 is defined as 14.
Analog input pins float all over the place unless they are connected, so getting a number when you disconnect does not mean a whole lot. That's the reason you need to have pull down/up resistors when you connect switch type devices.
Recheck your circuit. If you are using a breadboard, take a photo and post it or attach it to the posting.
One thing to check - are you getting IR light from the LED? If you point a webcam or other digital cam at the LED you can see if it is 'on'. That would at least prove half the circuit is working.