Input Devices¶
Light Sensor: Resistance Measurement¶
We began by characterizing a Light Dependent Resistor (LDR), a passive component whose resistance decreases as light intensity increases. This behavior stems from the photoconductive effect: photons striking the semiconductor material free electrons, lowering its overall resistance.
Using a multimeter, we measured the LDR’s resistance under two conditions:
- Direct sunlight: ~76 Ω
- Fully covered (dark): ~3.3 kΩ
This roughly 43× change in resistance confirms the LDR’s high sensitivity and makes it well-suited as a light detection element.
Voltage Measurement via Voltage Divider¶
To make the resistance change readable as a voltage — the form microcontrollers (almost) understand — the LDR is typically wired alongside a fixed resistor. The output voltage shifts depending on the LDR’s resistance relative to the fixed one. Or as we did here for simplicity and ease of understanding the output voltage shifts only based on our LDR.
We measured the resulting voltage indoors (with the sunlight fading), and still observed a clear difference:
- Lit (open): 1.523 V
- Covered (dark): 1.602 V
The small delta (~79 mV) compared to the resistance measurements is expected here: indoors, the lighting contrast is much lower than direct sunlight, so the LDR’s resistance barely shifts, and the voltage follows accordingly. Under full sunlight, the voltage swing would be significantly larger.
Potentiometer – Controlled Analog Output¶
Next, we worked with a potentiometer, a manually adjustable voltage divider. By rotating the wiper, we directly change the ratio of the internal resistance, producing a continuously variable output voltage. We confirmed the full range:
- Minimum rotation: 0 V
- Maximum rotation: 3.363 V (= V_in)

This clean 0–3.363 V sweep demonstrates the potentiometer as a predictable, user-controlled analog source — essentially a reference tool for understanding how analog sensors behave in general.
Oscilloscope Visualization¶
Finally, we connected the potentiometer to an oscilloscope and slowly varied the resistance while monitoring the output. As we turned the wiper, the voltage trace on the oscilloscope followed our hand movements in real time, drawing waveform-like “patterns.” This illustrated directly how a changing physical quantity — in this case, mechanical rotation — maps 1:1 onto a changing electrical signal over time.
How a Microcontroller Interprets These Values¶
A microcontroller like an ESP32 or Arduino cannot directly “understand” analog voltages — it only speaks in binary (0s and 1s). This is where the Analog-to-Digital Converter (ADC) comes in.
The ADC samples the incoming voltage at a set resolution. A 12-bit ADC, for example, maps the input voltage range (0–3.3 V) to a digital value between 0 and 4095:
where \(V_{ref}\) is the reference voltage (3.3 V) and n is the bit depth (in our case 12).
Bit depth defines the resolution of the analog-to-digital conversion — the higher the bit count, the finer the steps the converter can distinguish. A familiar analogy is image color depth: a 1-bit image only knows black or white, while a 24-bit image captures millions of shades. The same principle applies here. An 8-bit ADC maps the input voltage to 256 discrete levels, a 12-bit ADC to 4,096, and a 16-bit ADC to 65,536 — each additional bit doubles the resolution. Common ADCs in embedded systems operate at 8, 10, or 12 bits, while high-precision applications such as audio or scientific instrumentation may use 24 or 32 bits.
For our measurements: - 1.523 V → ADC ≈ 1888 - 1.602 V → ADC ≈ 1986 - Potentiometer at max (3.3 V) → ADC = 4095
These discrete integer values are what the microcontroller truly understands — everything inside runs on binary. In firmware, the processor maps these numbers to meaningful actions: dimming or brightening an LED based on ambient light, adjusting motor speed with a potentiometer, or firing an event the moment a sensor reading crosses a defined threshold. In this way, a physical phenomenon — light, pressure, rotation — is reduced to a stream of numbers the processor can read, react to, and control.