Basic Visible and Infrared Light Detectors

  This page features basic, visible light photo-detector circuits that can be used to detect trains or other light blocking objects.

  The sensors used for these circuits are silicon phototransistors or Cadmium Sulfide (CdS) photocells. Both of these sensors allow less current to flow when they are dark. (Phototransistors change their 'conductance' while photocells change their resistance depending on the intensity of the light falling on them.)

  The phototransistor or photocell would normally be placed between the rails in the circuits on this page.

  The Photo-detectors on this page use LM339 (Quad) or LM393 (Dual) voltage comparator, integrated circuits to detect the change in voltage across the sensor. For information on Voltage Comparators please see the Voltage Comparator Information page at this site.

  All of the circuits on this page are configured to have the LED's turn on when the sensor element is dark (covered by a train.) The LED's can also be made to turn off when a train is detected. This will be explained in the NOTES sections of this page.

  The supply voltage for the circuits is specified as regulated 12 volts DC but this can be changed if needed. In some cases the values of some resistors may have to be adjusted to compensate.


- Section 1 -

Visible Light Photo-Detector Circuits

Basic Phototransistor Detector

  In this circuit, when the light falling on the phototransistor (Q1) is blocked, its conductance will decrease and the voltage across Q1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.

Basic Phototransistor Detector

  The only critical part of this circuit is the value of resistor R1 which in most cases can be 470K ohms but may have to be increase if the room is dark or decreased if the room is well lit.

  Increasing the value of R1 will cause the sensitivity of the sensor to decrease. This may be necessary when the light falling on the cell is not very strong or shadows can affect the phototransistor.

  There are a number of phototransistors sizes and case styles. The smaller cases will be easier to hide but connecting wires may be more difficult.


Basic CdS Photocell Detector

  In this circuit, when the light falling on the photocell (PC 1) is blocked, its resistance will increase and the voltage across PC 1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.

Basic Photocell Detector

  Due to wide variations in CdS photocells it is usually best to install the cell and then measure its resistance under normal lighting conditions. A resistor with a value that is approximately 3 to 5 times the measured resistance of the cell is then selected for R1. For example; If the cell resistance is measured at 400 ohms then a 1200 to 2200 ohms resistor would be used.

  Increasing the value of R1 will cause the sensitivity of the sensor to decrease. This may be necessary when the light falling on the cell is not very strong or shadows can affect the photocell.

  This circuit can be adapted for use in dark areas by placing a small light above the photocell.


- Section 2 -

Infrared Light Photo-Detector Circuit

Basic Phototransistor Detector

  In this circuit the light falling on the phototransistor will be from an Infrared Light Emitting Diode (IrLED) but otherwise it is the same as the phototransistor circuit shown above.

  When the light falling on the phototransistor (Q1) is blocked, its conductance will decrease and the voltage across Q1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.

Basic Infrared Detector

  For information on calculating the value of current limiting resistors for the IrLED please see the Current Limiting Resistor Calculator page at this site.

  Follow this link for more information on this type of detector see: Across The Track Infrared Detectors.


Is The IR LED Working?

  Infrared light is not visible to the naked eye, however, a digital camera can be used to view the IR light if it does not have an IR blocking filter on the lens.

  The image may not be very bright but close-up or in a darkened area the light should be visible on the camera's display screen.


- Section 3 -

A Practical Quad Photo-Detector Circuit

  The next circuit is for a practical 4 photo-detector circuit using an LM339 Quad comparator IC. Although phototransistors are shown, photocells could also be used with the corresponding change in values for resistors R1 through R4.

  This circuit can also be used for infrared detector circuits as shown above.

Quad Photocell Detector

  The values for resistors R7 through R10 can also be changed depending on the required LED current. For information on calculating the value of current limiting resistors please see the Current Limiting Resistor Calculator page at this site.

  A printed circuit board with 8 comparator type photo-detectors can be seen at this link. 8 Photo-Detector Circuit Board


  This High Impedance Test Voltmeter circuit can also be used for testing phototransistors installations.


Phototransistor Detector Relay Driver

  By adding a PNP transistor to the basic detector circuit larger currents can be controlled. In this example a small relay is operated by the detector.

Relay Driver

Using Multiple Phototransistors

  More than one phototransitor can be connected to a single voltage comparator. This would allow transistors to be placed along a section of track to indicate when a train is anywhere in that section.

  As long as the train is long enough to cover two sensors the circuit will continuously detect the train.

Multiple Sensors

  Circuit 2 on the schematic is simpler but the phototransistors must have better lighting than Circuit 1 to get good results.


LM339 Data sheet - National Semiconductor (.pdf)

LM393 Data sheet - National Semiconductor (.pdf)

Pinout Diagram For Various Devices.

Return to the Main Page


Please Read Before Using These Circuit Ideas

  The explanations for the circuits on these pages cannot hope to cover every situation on every layout. For this reason be prepared to do some experimenting to get the results you want. This is especially true of circuits such as the "Across Track Infrared Detection" circuits and any other circuit that relies on other than direct electronic inputs, such as switches.

  If you use any of these circuit ideas, ask your parts supplier for a copy of the manufacturers data sheets for any components that you have not used before. These sheets contain a wealth of data and circuit design information that no electronic or print article could approach and will save time and perhaps damage to the components themselves. These data sheets can often be found on the web site of the device manufacturers.

  Although the circuits are functional the pages are not meant to be full descriptions of each circuit but rather as guides for adapting them for use by others. If you have any questions or comments please send them to the email address on the Circuit Index page.

Return to the Main Page

07 March, 2010