Build and use a simple light detector sensor circuit

By: Jeremy Cook

Electric lighting requires energy. If you’re in a situation where electricity is limited (e.g., using a battery-powered device), you don’t want to waste valuable power when the sun is out or when other lights are already shining. In this post, we’ll construct a light sensor circuit to allow an LED to turn off automatically when it senses light.

Light Sensor Circuit: LDR, Transistor, Resistor

For this experiment, you’ll need the following components. Values used are in brackets but can be varied depending on the input voltage and components available:

Hook up your circuit according to the “DARK DETECT” schematic below. When properly implemented, the absence of light will turn the LED on. When sufficient light shines on the LDR, it turns off.

  Light-Circuit-Diagram-Reverse-R2-and-LDR-to-detect-light-or-dark-image-2-body

Light Circuit Diagram: Reverse R2 and LDR to detect light or dark

Light Sensor Circuit Explanation

As light shines on the LDR, its electrical resistance is lowered from the multiple MOhm range in total darkness to the 100 Ohm range with sufficient light. The LDR and R2 act as voltage dividers, with voltage at VX dictated by VX = VDC * RLDR / (RLDR + R2). Current begins to flow from the collector (3) to the emitter (1) when VX/base voltage is sufficiently high (around .6 VDC for my setup). When active, current flows through the LED and transistor, inhibited by R1 to protect the LED.

To dynamically change the point at which the LED switches on, you can use a variable (tuning) resistor for R2. As its resistance is turned higher, a greater LDR resistance—and thus a lower light level—is required to reach sufficient voltage (VX) to activate the transistor and light up the LED.

 Detecting-darkness-1-image-3-body Detecting-darkness-2-image-4-body

Detecting darkness | Credit: Jeremy Cook

Conversely, you can reverse the position of R2 and the LDR to turn the LED on with sufficient light. In this situation, as the LDR’s resistance decreases with more light, the voltage drop from VX to ground becomes higher. When VX becomes sufficiently high, it allows current to flow through the LED.

Microcontrollers, Operational Amplifiers, and “Things” Control

Switching on an LED based on ambient lighting is certainly useful for illumination. However, this sort of light-dependent resistance circuit setup can be applied elsewhere.

Differential voltage input (from an LDR or otherwise) can be used with an operational amplifier for switching instead of a single transistor. You can also use a microcontroller (or other computing devices with an analog-to-digital converter) to actuate equipment based on ambient lighting. We explain how to use such a sensor with an Arduino microcontroller setup here.

Measuring light (or lack thereof) can be used for presence detection or to pass signals while maintaining electrical isolation. With the help of local computing resources, data can even be sent to the cloud and amalgamated with other sensing devices, allowing control possibilities limited only to your imagination. That’s not bad for an extremely simple and inexpensive sensor!

See related product

2N2222A

Rectron RF BJT View

ArrowPerks-Loyalty-Program-Signup-banner-EN


Latest News

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here