Photo Reflective Sensor Setup ?!

I'm having a trouble setting up this sensor on a board and connecting it to my Arduino, can anyone help me ?!

pic: http://www.seeedstudio.com/depot/images/product/rs081.jpg

data sheet: http://store.fut-electronics.com/Products/PDF/photoReflectiveSensor.pdf

All the details are in the datasheet:

The LED needs 20 mA and has a drop of about 1.2V.

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.

is that correct ?!

Sounds correct. You don't say what your software is doing? Maybe post your code?

int val0=0;
int irPin0 = 0;
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  val0 = analogRead(irPin0);

  Serial.print(val0);
  Serial.print("\n\r");
  delay(1500);
}

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 :smiley:

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);
}

but isn't (0) similar to (A0) ?!!! because as I mentioned I get a response when I connect the circuit to pin A0, but unfortunately the wrong response :confused:

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.

still getting zeros, i tried the cam thing, but i can't notice anything. I replaced the sensor with an led and it worked !!!