Step 3Schematics
The reset input is not connected. This is not best practice. Better would be to use a 10K resistor as pull up. But it works fine for me without and it saves a resistor.
To keep the circuit as simple as possible, I used the internal oscillator. That means we save a crystal and two small capacitors. The internal oscillator lets the controller run at 1.2MHz which is more than enough speed for our purpose.
If you decide to use another power supply than 5V or to use another LEDs you have to calculate the resistor R1. The formula is: R = (Power supply V - LED V) / 0.002A = 1650 Ohm (Power supply = 5V, LED V = 1.7V). Using two low current LEDs instead of one, the formula looks like this: R = (Power supply V - 2 * LED V) / 0.002A = 800 Ohm. Please note, that you have to adjust the calculation if you choose another type of LED.
The value of the resistor R2 depends on the used LDR. 1KOhm works for me. You may want to use a potentiometer to find the best value. The cicuit should be able to detect light changes in normal daylight. To save power, PB3 is only set to high, if a measurement is done.
Update: the schematic was misleading. Below is a correct version. Thanks, dave_chatting.
| « Previous Step | Download PDFView All Steps | Next Step » |











































http://ledcalculator.net
I think you meant to say that PB3 is set high when you take a measurement, not PB2.
Also, the resistor formula is a bit confusing as it stands. Might be better as:
R = (Supply voltage - LED voltage)/0.002
It's also worth noting that although red and amber LEDs generally have a forward voltage of something like 1.7V at a current of 2ma, high brightness green, blue, and white LEDs have a much higher forward voltage (over 3V).