I am trying to make a simple motion detector for objects within a few feet in a very small footprint with minimal parts. I don't need to know much info about the motion just simply if there was motion and the rate of the motion. I do not need to know the absolute level of light.

So far I have had pretty good luck doing this using a basic photo-transistor circuit and a micro-controller ADC with integrated gain.

The issue arises when I change light levels from a dark room to light room to cloudy day, the photo-transistor can easily saturate depending on overall light level.

A way to avoid this would obviously be to use a variable resistor type circuit, like a digital potentiometer or a voltage controlled JFET. These circuits are a little more complicated then I was hoping and would require constant checking and adjusting of the resistance.

My question is, since I do not need to know the absolute light level, is there any circuit that can automatically control the photo-transistor so that It remains out of saturation in any light level?

(I'm not too experienced in electronics, but is there a way to provide feedback with some hysteresis to a jfet or other resistance like device that would keep the photo-transistor between VCC and GND while allowing some high frequency fluctuations? (movement)

basic phototransistor circuit

  • \$\begingroup\$ This is where I'd pull out a MCU and do it in software. \$\endgroup\$ – Ignacio Vazquez-Abrams May 28 '15 at 16:41
  • \$\begingroup\$ You could replace R1 with a digitally controlled pot and let the MCU dynamically control the gain. \$\endgroup\$ – tcrosley May 28 '15 at 16:48

Ambient light levels are always a problem. One possible solution is to use I(nfra) R(ed) at high frequency. It just happens that TV zapper technology is available at very reasonable cost. The detector IC does the work for you. A simple 38kHz IR oscillator made from the ubiquitous 555 (astable) with IR led will generate the signal.

enter image description here

A second 555 (wired as a re-triggerable monostable) is connected to a 38kHz IR sensor IC. This will keep the output high until it fails to detect the 38kHz signal.


If you assume that that the light level (natural ambient light?) will not change rapidly, all you need is a slow loop to control the bias.

This could be done with something like a low-pass filter and a voltage controlled current source (an op-amp and a transistor). The low-pass filter slows the current source input down. Try something in the 10's of seconds for the slow loop time constant.

Here's a simulated response to a step change in light (from 1.2 to 2.4mA) with a 20s time constant:

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.