Sensor: The LDR The Light Dependent Resistor (LDR), also called a photoresists or photocell is simply a resistor whose resistance value decreases based on the amount of light which strikes its surface. But in our case at least one of the values will vary; which is exactly what we want. This should leave us with a voltage varying based on the amount of light reaching the LDR. LDRs are in phones, TVs, cars, cameras, light fixtures — anything that needs to react to the amount of ambient light. For our experiment we are going to use a 10K Ohm fixed resistor, and, of course, 5V as the voltage source. In order to use them with our Nano, we need to use that varying resistance in order to vary the voltage on an analog pin so that we can read a value. Once we have that value we can associate it with an amount of light. Although every LDR will react slightly differently, these will generally vary from as little as 200 Ohm in full sunlight to over 1,000,000 Ohms in near total darkness. If we wire the LDR as R1, then at full brightness we get: The easiest way to achieve that is to create a voltage divider with the LDR and another fixed value resistor. We briefly mentioned voltage dividers when we talked about the poteniometer, and this is no different, except we are replacing the knob with the LDR. Let’s look at the voltage divider in more detail. 10000 / ( 10000 + 200 ) * 5 = 4.9v A voltage divider consists simply of two resistors connected in series between a potential and ground, with a third connection at their junction point. The voltage as measured from this junction point to ground is the divided voltage, and will be reduced by a specific amount based on the values of the resistors. wikipedia.org To determine how much the voltage will be reduced you can use the simple algebraic equation: Vout = R2 / ( R1 + R2 ) * Vin When R1 == R2, then it can be simplified to: Vout = Vin / 2 © 2016 Dataseam and a full dark: 10000 / ( 10000 + 1000000 ) * 5 = .05v Which is a pretty good range of 4.85v . Since analogRead() returns 1024 values over 5v, 1 per .005v, we should have around 970 distinct values. Experiment: Feeling Lux-y? Components Wiring Diagram ✓Nano ✓10K Ohm Resistor ✓LDR Connection Instructions Connect the 10K Ohm resistor from Ground to an open column on the breadboard, to that same column connect a jumper to pin A2. Also on that column place one leg of the LDR. Connect the other leg of the LDR to 5V, either directly or or by using another open column on the breadboard. Sketch(es) LDR.ino Analysis Questions Programming Tasks The provided program will dump the raw values read from the LDR to the Serial monitor. Experiment with covering the LDR and exposing it to a bright light source ( flashlight or similar ), and observe the range of values. (optional — programmatically track the highest and lowest values, and continually output them) Use that range and the map() function to also output number ranging from 0-255 based on the LDR’s raw value. Try to use as much of the 0-255 as possible. Now combine this circuit and software with either the Arrays and LEDs or Sound Detection program, so that the overall brightness of the LED strip dims in low light and gets brighter as the ambient light does. © 2016 Dataseam