May 22, 2013 | Circuits |
Say you have a microcontroller circuit that does something when it goes dark. To save power, you want to put the chip to sleep when the ambient light drops below a certain level. One way to do this is using an LDR and an op-amp comparator.
Here is the schematic:
In the above circuit, the reference voltage at the non-inverting terminal of the op-amp is VCC/2. When it's dark, the LDR has a high resistance (over 20K), and the voltage at the inverting terminal (pin 3) is going to be less than VCC/2. Hence, the output of the op-amp will go to high when it is dark. When sufficient light falls on the LDR, its resistance falls, and the voltage at the inverting terminal (pin 2) exceeds VCC/2. At this point, the op-amp output goes low. We can control the threshold at which it goes from low to high by adjusting the potentiometer R1.
Here is what the circuit looks like on a breadboard. The supply is 5V regulated.
In this case, I am using the LM358 - a very popular general-purpose Op-Amp IC. This works fine for our purpose, but do note that there are dedicated comparator ICs with better switching characteristics for critical applications.
In my next post, I will describe how to hook this up to an ATmega168 and wake it up from power-save mode.
We love hearing from our readers. Email us at email@example.com for questions or comments on this article. If you found this article useful, please support us by buying some of our Open Source hardware products - like ZeroDriver - an Arduino Zero compatible motor driver for robotics. ZeroDriver is crowdfunding right now. Please click here to support our campaign. and bring this product to market!