Basic Electronics, Chapter 3: Challenge 3 solution (light sensor and pull-up) Circuit: 5 V, LDR on top (R1), fixed resistor R2 to ground, Vout from the middle. Vout = 5 x R2 / (R_LDR + R2) (a) R2 = 10 k Dark, R_LDR = 500 k: Vout = 5 x 10 / (500 + 10) = 50 / 510 = 0.098 V Room, R_LDR = 15 k: Vout = 5 x 10 / (15 + 10) = 50 / 25 = 2.000 V Bright, R_LDR = 2 k: Vout = 5 x 10 / (2 + 10) = 50 / 12 = 4.167 V Swing: 0.098 V to 4.167 V, with room light at 2.0 V (a little under half supply). (b) Make room light give 2.5 V (half supply) Half supply needs R2 = R_LDR at that light level, so R2 = 15 k (an E12/E24 value). Dark: Vout = 5 x 15 / (500 + 15) = 75 / 515 = 0.146 V Room: Vout = 5 x 15 / (15 + 15) = 75 / 30 = 2.500 V Bright: Vout = 5 x 15 / (2 + 15) = 75 / 17 = 4.412 V Swing: 0.146 V to 4.412 V. Room light is centred, and the bright end has more room before reaching 5 V. The dark end is a little higher because 15 k is larger, but it is still a clear "dark" level. (c) Pull-up for a push button on 3.3 V Pressed current limit: R >= 3.3 V / 0.2 mA = 16.5 k ohm Leakage limit (1 uA, 0.99 V allowed drop): R <= 990 k (not a constraint) Pick the next standard value above 16.5 k: 22 k (E12). (Anything from 22 k to 47 k is reasonable; 10 k also works if 0.33 mA is acceptable.) Pressed current: I = 3.3 / 22 k = 0.15 mA (under 0.2 mA: passes) Power in resistor (pressed): P = V^2 / R = 3.3^2 / 22,000 = 10.89 / 22,000 = 0.000495 W = 0.495 mW (trivial for a 1/4 W part) Rise time constant: tau = R x C = 22,000 x 20e-12 = 4.4e-7 s = 0.44 us (the line reaches 95 % of the rail after about 3 tau = 1.3 us: much faster than any button or a microcontroller reading it) Open-button level: 1 uA x 22 k = 22 mV below the rail, so a solid logic 1. Pressed: the pin is held at 0 V by the button, so a logic 0. Build check (expected, using your own measured LDR resistances): Use the formula in (a) with the resistance your meter shows in each light condition. Vout / 5 V must equal 10 / (R_LDR + 10) with R in k ohm. Checklist [ ] LDR on top: output rises with light [ ] R2 equal to the LDR resistance at the light level that matters gives half supply there [ ] pull-up: lower limit from pressed current, upper from leakage and speed [ ] check the pressed current, power and rise time with the real value chosen