I am trying to build a very simple proximity switch where four (4) sets of LTE-5208A 940nm infra red (IR) emitters are each paired with a LTR-3208E photo transistor (NPN) for a model railroad project I am working on. In this project, there are two tracks parallel to one another, and there is a proximity switch (for lack of a better description) on the left side and the right side of a railway crossing for each track to detect when a train comes from either direction... and when the level crossing is clear. The small Teensy 3.1 is perfect to perform the necessary logic and make the lights flash appropriately.
I have loosely based my design on the following references:
With the following circuit (see attachment), I am able to get a fluctuation in voltage of almost 0V to 0.1V… and if I increase the 100kohm to 1Mohm, then I get almost 0.5V to input pin #4 as measured on a MultiMeter… but this is not obviously enough to trigger the input.
I am not an expert by any means with electronics and have two questions:
The code for the program is quite simple and looks as follows, using the on board LED at pin 13 as an indicator for test purposes.
Thanks for any help that you can provide! Rudy
I have loosely based my design on the following references:
- Evil Mad Scientist IR detection of sunlight using the LTR-5280 - http://www.evilmadscientist.com/2008/a-dark-detecting-circuit-for-your-jack-o-lantern/.
- Arduino Forum: IR led sensing IR led Reflections - http://forum.arduino.cc/index.php?topic=164771.0
- Evil Mad Scientist Octolively - http://shop.evilmadscientist.com/productsmenu/tinykitlist/411
With the following circuit (see attachment), I am able to get a fluctuation in voltage of almost 0V to 0.1V… and if I increase the 100kohm to 1Mohm, then I get almost 0.5V to input pin #4 as measured on a MultiMeter… but this is not obviously enough to trigger the input.
I am not an expert by any means with electronics and have two questions:
- Is there any way to do this circuit with out a NPN transistor such as a 2N3904. Can one do this with one transistor given the input is transistor based, or do you need a darlington pair.
- What is the required voltage to trigger a digital input on the Teensy 3.1
The code for the program is quite simple and looks as follows, using the on board LED at pin 13 as an indicator for test purposes.
Code:
// Simple IR Test Program for LTE-5208A and LTR-3208E
const int LED = LED_BUILTIN;
const int IR_OUTPUT = 3;
const int IR_INPUT = 4;
const int WAITTIME = 500;
void setup() {
pinMode(LED, OUTPUT);
pinMode(IR_OUTPUT, OUTPUT);
pinMode(IR_INPUT, INPUT);
}
void loop() {
digitalWrite(LED, HIGH);
digitalWrite(IR_OUTPUT, LOW);
delay(WAITTIME);
digitalWrite(LED, LOW);
digitalWrite(IR_OUTPUT, HIGH);
if(digitalRead(IR_INPUT)) {
digitalWrite(LED, HIGH);
}
delay(WAITTIME);
}
Thanks for any help that you can provide! Rudy