← Back to the chapter · Next detail →

Technical detail · Hardware Prototyping: First-Build Experiments

LED current and LDR divider arithmetic

In a voltage divider, the LDR and a fixed resistor sit in series across the supply; their shared junction gives a voltage that changes with resistance. A 12-bit code has 4096 possible values, from 0 to 4095; the voltage range used for that conversion depends on the board and its settings.

The mathematical gist. On a 3.3 V rail, a red LED dropping 2.0 V needs (3.3−2.0)/0.010=130 Ω(3.3-2.0)/0.010=130\ \Omega for 10 mA. A 10 kΩ divider with an 8 kΩ LDR produces 1.83 V, or about code 2,275 on a 12-bit ADC; at 1 MΩ it falls to 0.0327 V and code 41. The shrinking code movement is the divider curve, not a linear light scale.

← Back to the chapter · Next detail →