hi, I am trying to test a photo transistor like this one http://www.eleparts.co.kr/epdf/SENSOR/ST-3811.pdf) and an infrared emitter like this onehttp://www.eleparts.co.kr/epdf/SENSOR/EL-1KL3.pdf
I need to use this photo transistor as a switch, and this emitter as the swtich's trigger wire.
Right now, I connected the circuit like this.
Gnd - photo transistor - 10k ohm resistor - 5v
And, digital pin 3 in between the ransistor and the resistor.
And, I used this code to test the transister.
int sensorPin = 3;
int ledPin = 13;
int sensorValue = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
sensorValue = digitalRead(sensorPin);
digitalWrite(ledPin, sensorValue);
}
I tried to test this transistor in a complet darkness but it doesn't work.
The digital pin 13 just kept on lighted.
Could you please advise me what is wrong with my trial?
Try a resistor with a much higher value (100K - 1m) and connect it to an analogue pin for trials. Getting a clean switch over on a digital pin is tricky doing it blind without knowing what the phototransistor and led arrangement can sink (it depends on how you arrage the optics as much as the components). If you can get an analogue reading to go well above and below about 400 when you switch the led, you stand a chance with a digital pin, but you need to experiment with the resistor values.
Hi, pluggy. Thank you.
I didn't have a 100k ohm resistor but 10k ohm.
Luckly, I had 10 pieces of 10k ohm resistors, so I connected all those 10 pieces in parallel.
But, the digital pin 13 is still kept on.
100k was suggested as a minimum, you need to hook your circuit up to an analogue pin in order to determine just how sensitive your circuit is. In a similar circuit with an optical sensor (LED / Photo transistor) I have, I have a 470k resistor. With an analogue reading with the light on and off it gives some clues as to what the problem is. Just make a the main program loop read the analogue pin and squirt it out of the serial interface so you can read the figures on the serial monitor. If you have a reasonable digital multimeter, measuring the voltage at your pin 3 takeoff point will suffice if you don't want to write a sketch. You're going to be struggling trying to get such a digital circuit working 'blind' which is what you're doing now. A digital pin just switches on and off with the trigger point at around 2 volts, 2v corresponds to around a value of 400 from the ADC on an analogue pin. Your sketch is written to switch the LED on when the digital pin is high, which suggests that the photo transistor isn't allowing enough current to sink to ground to drop the voltage enough to turn the digital pin low and the LED off. The resistance needs to be higher in other words.
BTW the resistors in the photo are in series which is what they should be, if you'd wired them in parallel as you stated they'd have a collective resistance of 1k. The one on the ground rail appears to be short circuited which would give the resistance as 90k.
Just like the first trial, "transistor activating" is keep appearing on the serial monitor while the LED is kept on flashed on the digital pin13
Am I following you correct? Please correct me if I am off from your point.
I am sorry, I confussed the expression series and parallel.
That's very nice of you. Thank you very much.
I modified the code and tested.
In the ambient light, the value is 1023, 1022.
When i just grabbed the transistor by my fingers so that I can shade it, the value is decreased.
This is the reading I got.
With the circuit in the photograph, I would expect the reading to be low in the light (when the pt is passing current to ground and dragging the voltage down) and high in the dark when its impedance is much higher and the voltage is pulled to 5v by the resistors. Is the PT connected the right way round ? or is my logic completely screwy ? According to the specs, it does respond to visible light at the red end of the spectrum, but its peak sensitivity is in infra red. Pointing your TV remote at it as mem suggests may yield further clues.
Hello, gentlemen,
i am sorry for my late reply.
I haven't made a circuit for the infra red emitter yet.
I just tried to power the emitter by connecting it with 5V and Gnd of arduino and tried to see through a digital camera. I couldn't see anything. Could you tell me how to connect the emitter?
Instead of the emitter, i tried to point TV remote control on the photo transistor and I got this reading.
The values below 1000 is appeared when I press the remote control.
Regarding the connection status of photo transister, could you take a look at this picture and tell me whether it is connected correctly?
The infra red LED will need a resistor if you haven't already burnt it out. I'd suggest about 200 - 500 ohms for 5 volts. If your breadboard is like mine, the rails with the red and blue lines are commoned along their entire length, so the resistors plugged into the red rail are short circuited and have no resistance.
The photo transistor bit seems to be in hand, I was picking up on his wiring the LED ('emitter') and it not appearing to work. (it isn't in the photos, I've looked at spec sheet and it appears to be a metal sheath with a glass lens). Just using ambient light should serve at this stage.
The resistors in series aren't an immediate problem, but may well be if he ever gets to the digital pin bit.
Can't help thinking a digital multimeter would make life a lot easier.......
Thank you for advising me.
Yes, the red rails are all commoned :-[
I put resistors again without putting them in the power rail.
I also reversed the polarity of the photo transistor so that the emitter side goes to Gnd.
I tried serial monitor and it received this.
When the photo transistor is exposed to ambient light, the value is below 100. When I hold the transistor by my fingers, 1023 appeared.
I don't have my multimeter right now, but I will try to do that soon.
P.S.
Do you have by any chance the spec sheet of SP-1CR2 version of the detectors? I am trying to find similar detectors locally here by comparing the specifications.
Looks like you're getting somewhere, the circuit is behaving as it should. If you can reliably get readings above and below about 400, theres no reason it shouldn't work with a digital pin. Now its down to the IR emitter and its optical arrangement with the photo transistor. Try it in the dark or subdued light with your LED and / or TV remote.
The 0 appeared whether the photo transistor is in a complete darkness or in ambient light.
When I touch the photo transistor, 1 appeared. The responding was late. 1 isn't appeared immediately as soon as I touch the photo transistor.
It is the same thing under ambient light.
I tried with TV remote control, but it doesn't have any effect on the photo transistor, the serial monitor keep showing 0 when i beam the light of tv remote control to the photo transistor and showing 1 when I touch the photo transistor.
I checked the voltage of the digital pin 3 with a very reliable multimeter.
It measured 2.487V.
Did you get the analog input version responding to the IR remote control?
I suggest you go back to the wiring you had used for post#14 and see what readings you get when you aim the remote beam on the photo transistor.
Is it the action of touching the PT or depriving it of light thats causing the change ?. If its responding to light in either circuit, you should get similar results by covering it with a cup or something. If its just responding to touch it sounds like a dodgy connection on the breadboard. The voltmeter reading is about the change between light and dark, not about a one time reading. When you're reading an analogue pin, you're just measuring representation of a voltage. 0 = 0V and 1023 = 5V. The voltmeter is a quick method without writing a sketch. On the digital pin, 0 is below about 2 volts and 1 is above 2 volts.
The wiring is same as the post #14. I modified the sketch for the analog and tested again.
This is the readings from the serial monitor when i just let the photo transistor under the ambient light(without touching or beaming tv remote control)
This is the reading when I beam tv remote control light to the photo transistor. I think there is no difference. I beam the light as soon as I turned on the serial monitor.
This is the reading when I just grabbed the photo transistor to block any light. I grabbed the photo transistor as soon as I turned on the serial monitor.
Regarding the result I posted on the previous post, the 1 appeared only when I touch the photo transistor. The 1 didn't appeared immediately i touch the photo transistor.
It didn't responded to any light.
I returned to the digital pin reading.
I also checked the voltage of the pin 3(digital pin).
The value was very very unstable. I don't know why.
Anyway, the measurement is like this.
Transistor under ambient light : 168mV~225mV
When the transistor is blocked(grabbed) by fingers : 2.5V
When the transistor is beamed with tv remote : 83mV~220mV
I triple checked on the voltage readings. :