Problems using IR emmiter and detector with Arduino?

I'm trying to build a very basic circuit containing an TIL32 photodiode and a TIL78 phototransistor. Basically, I want to emmit IR light and detect it with the phototransistor. I already verified that my photodiode is working, indeed, so I think the problem is with the phototransistor. I'm really newbie with this, so I'm probably doing something wrong. I've put the photodiode in series with a 330Ohm resistor and the phototransistor in series with a 10 K resistor, wired them both from 5V to GND and also wired the phototransistor to pin 3 in the Arduino. I just want to input the pin state to the serial monitor, checking whether or not the phototransistor is recepting IR light.

The code I used is this one:

int sensorPin = 3;
int sensorValue = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  sensorValue = digitalRead(sensorPin);
  Serial.println(sensorValue);
}

Please post your circuit (drawn on paper and photographed if necessary).

Do you have a meter that can read voltage? If so then you can check if the voltage on pin 3 is changing at all when exposed to IR light. If you don't have a meter try connecting it to an analog pin instead and observing if the reading changes.

Its sometimes possible to "see" IR light using the camera in your smartphone- useful to check if the IR source is actually working.

Ok, I've drawn a rough sketch (please, sorry if there are any mistakes in there). Also, I've tried connecting the phototransistor to the Arduino Analog Input. I've noticed that, when i detach the photodiode, the readings in the monitor serial register 1023. With the photodiode, they oscillate between 1014-1015. |500x300

You do understand that the photodiode is an input device, not an emitter?

I'm not sure. Could you explain? I'm trying to assemble the circuit described in this website: http://garagelab.com/profiles/blogs/tutorial-how-to-make-an-optical-tachometer-with-ir-led-and-photot My final goal is to build a optical tachometer, but for the moment I just want to understand how to use those things.

vinicius0197: Also, I've tried connecting the phototransistor to the Arduino Analog Input. I've noticed that, when i detach the photodiode, the readings in the monitor serial register 1023. With the photodiode, they oscillate between 1014-1015.

That means that the light of the IR LED is not strong enough to pull the photo transistor low. Measure the voltage across the IR LED. It should be ~1.2volt. You could also increase the value of the 10k resistor (10-100k) to make the photo diode more sensitive. Or use the internal pullup resistor in pinmode. Leo..

Are you sure you have the phototransistor connected the right way? The collector needs to be connected to the resistor and arduino pin while the emitter connects to ground. (Its not clear from your circuit which is which)

vinicius0197: I'm not sure. Could you explain?

A photodiode isn't the same as an LED. You've used the term photodiode in your first post and drawn a photodiode symbol on your schematic, so I'm assuming you're trying to use the wrong component. Have you got an IR LED?

https://en.wikipedia.org/wiki/Photodiode

Martin-X:
A photodiode isn’t the same as an LED. You’ve used the term photodiode in your first post and drawn a photodiode symbol on your schematic, so I’m assuming you’re trying to use the wrong component. Have you got an IR LED?

Photodiode - Wikipedia

Well, what I have is a photodiode emitter. I used the tip someone has given above and tried “seeing” the infrared light with a smartphone camera and it worked. I tought photodiode and IR LED were the same thing.

rw950431:
Are you sure you have the phototransistor connected the right way? The collector needs to be connected to the resistor and arduino pin while the emitter connects to ground. (Its not clear from your circuit which is which)

I think I’ve got that right, actually.

Wawa:
That means that the light of the IR LED is not strong enough to pull the photo transistor low.
Measure the voltage across the IR LED. It should be ~1.2volt.
You could also increase the value of the 10k resistor (10-100k) to make the photo diode more sensitive.
Or use the internal pullup resistor in pinmode.
Leo…

I will try doing that. Thanks for the advice!

I recommend using a standard IR LED here. Then read it with the IR photodiode. I wrote a whole blog article about how to wire it and read distance measurements between an obstacle and the IR pair.

Here is how you would wire them to get the desired output you want: