Digtial Light Sensor

7,376

109

15

Posted in TechnologyElectronics

Introduction: Digtial Light Sensor

About: IoT Related Projects

Sensors make working with any project fun and simple to do, there exists thousands of sensors and we get the choice to choose the right sensor for our projects or needs. But nothing is better than designing your own DIY sensors to work with a wide range of micro-controllers so you have the exact design you need for your project.

This instructable will be a part of a series of instructables in which I show you how to build sensors compatible with most microcontroller you can find. In the last two instructables I showed you how to how to make a tilt sensor,vibration sensor and how to make a Touch sensor.

In this instructable I'm going to show you How to to design your own light sensor, which could be used as a day and night switch or as a part of a security system.

Step 1: Tools and Components

Here is a list of what you will need to get started with instructable,

Step 2: Circuit

The circuit is based on LM358 IC which is an OP-AMP with an operating voltage range of 3v to 32v which is suitable to work with most micro-controllers of logic level 5V or 3.3V. The LDR is connected to the non inverting terminal of the op-amp and each time light is detected by the circuit it generates a High pule across the output and the LED turns ON.

Signal can be fed to the microcontroller via the Pin 1 of the LM358 IC.

Step 3: LDR

The LDR is a electronic component whose resistivity changes as light is incident on it. When no light is incident on it the LDR offers Highest resistance and when light is incident on it the resistivity decreases, thereby generating a signal across the non inverting terminal of the Op-amp.

Step 4: Senstivity

The sensitivity of the circuit can be changed by varying the 10K pot, if the LED remains on even when no light is detected, you should change the pot with a screw driver (plastic one recommends), until the LED turns off.

Step 5: Going Further

After you have tried it out on a breadboard you could build it on a PCB or as an Arduino shield, for the spring you should use single strand wire. If you would like me to write a code for your microcontroller feel free to PM me.

In the next instructable I will show you how to build a pressure sensor.

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Woodworking Contest

      Woodworking Contest
    • Microcontroller Contest

      Microcontroller Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    15 Comments

    I am enjoying your mini LM358 series of articles - keep it up :)

    I created a daylight sensor similar to this circuit using 555 timer chip instead of the opamp. The 555 allows hysteresis so the circuit would turn on when the analog sensor is 2/3 peak level and turns off when it drops below 1/3.

    1 reply

    This is one of the applications that the notorious 555 was designed for in the first place, and that it is a good design is proven by the fact that it is still in production after almost 50 years ! ;-)

    I believe you have an error in your schematic. You show both sides of your voltage divider, consisting of R4 (LDR) and R3 connected to ground. I don't see how you can generate a voltage going to pin3 like that ;-)

    3 replies

    Pin 8 of the LM358 is connected to V+ and Pin 4 is connected to V- (GND), so the schematic is technically correct. There are improvements one could make with this circuit, of course, but it does demonstrate the point as is.

    You are quite right about the misplaced connection from the LDR (R4) to ground--that should have been to V+.

    No, that's not what I'm saying.

    You show both sides of your voltage divider, consisting of R4 (LDR) and R3 connected to ground. Both the top and bottom of your voltage divider is connected to ground.

    You can not generate a voltage going to pin3 like that.

    1. First make one with a pot

    2. Adjust the pot to the desired level of sensitivity

    3. Measure the upper and lower value of the (disconnected) pot

    4. Replace pot by two approximating resistors

    and Bob's your uncle !

    Thankyou louis.m

    There is nothing ¨digital¨ to your design, the LM358 is just a dual analogue opamp !

    Also the diagram is a bit straggly, if drawn from left to right (and top to bottom) it would look much better and be easier to understand, and power lines in a small diagram like this are no overdoing !

    1 reply

    In this case, the LM358 is used as a digital output circuit, even though it is normally used in analog applications. Here, the input is an analog signal being compared to an analog reference (the wiper on the voltage divider), and the output of the circuit is digital, either V- or V+.

    This is pretty good, but please add a real schematic as well. Just using the pinout of an actual device doesn't help when wanting to use a different op amp.

    Also, could you add how you came up with the resistor and pot values please.

    1 reply

    This circuit uses the op-amp without feedback, which means that it is acting as a comparator. It really doesn't matter too much whether the pot is 1 K or 100 K, it is simply working as a voltage divider. There should be a resistance between the wiper on the pot and the inverting input on the op amp since it tries to act as a virtual ground--10 K would be reasonable. The resistance of the LDR in the dark determines what the minimum voltage will be seen at the non-inverting input of the op amp. The more light appears at the LDR, the higher the voltage. Whenever the voltage at the non-inverting input exceeds the voltage at the wiper of the voltage divider, the output of the amplifier will shift from V- to V+, and the LED will illuminate.

    In your photo's, the POT looks like it is marked with '104'. Is that not "100K" ?

    Also, what value is the LDR?