Build it step by step
0 of 7 doneWire the working divider
5V to the LDR, the LDR to A0 and the resistor, the resistor to GND.
Upload and watch the numbers
Open the Serial Monitor at 9600 baud.
Cover and uncover the LDR
The number falls in the dark and rises in the light.
Look away while the helper plants a fault
The readings stick or wander.
Measure A0 with the meter
Compare with the voltage the sketch prints.
Trace the wires
Find the moved resistor, the open ground or the wrong hole.
Fix one fault at a time
Check the readings come back to normal.
How do you build a light sensor fault hunt?
An LDR divider on a Nano should rise and fall with the light, but a planted fault makes it read full or flat. Build it working, have a helper plant faults, and find them by measuring the voltage at the analog pin. You need Arduino Nano, LDR Photoresistor, Resistor 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 50 minutes.
- Level
- Beginner
- Time
- About 50 min
- Parts
- 5
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- PassivesBuyResistor 10 kΩ × 1
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| LDR leg 1 | Nano 5V | Top of the divider |
| LDR leg 2 | Nano A0 and 10 kilohm resistor leg 1 | The divider output |
| 10 kilohm resistor leg 2 | Nano GND | Bottom of the divider |
Code
The LDR and the 10 kilohm resistor form a voltage divider, so the analog pin sees a voltage that rises as the LDR gets brighter and its resistance falls. In room light the reading is usually somewhere in the middle, in the dark it is near zero, and in strong light it is high. The sketch prints the raw number, the voltage, a bar and a hint if the value is stuck at an end. Fault hunt: build it working and note the readings in light and dark. Then ask a helper to plant one fault at a time while you look away. Safe faults are moving the 10 kilohm resistor to 5 V instead of ground, which makes the pin read high all the time, leaving off the ground end of the resistor, which makes the reading wander, and moving the sensor wire one hole away from A0. Use a meter on the A0 pin and trace each wire to find the cause before you touch anything.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const uint8_t SENSOR_PIN = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int raw = analogRead(SENSOR_PIN); // 0 to 1023
float volts = raw * 5.0 / 1023.0;
Serial.print("raw ");
Serial.print(raw);
Serial.print(" volts ");
Serial.print(volts, 2);
Serial.print(" ");
for (int i = 0; i < raw / 32; i++) Serial.print('#'); // a quick bar
Serial.println();
if (raw > 1000) Serial.println(" Reads full: the pin may be tied to 5 V, or the bottom resistor is missing.");
if (raw < 20) Serial.println(" Reads zero: the pin may be tied to ground, or the LDR is not connected.");
delay(400);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
raw 512 volts 2.50 ################ raw 513 volts 2.51 ################ raw 512 volts 2.50 ################ raw 513 volts 2.51 ################ raw 512 volts 2.50 ################ raw 511 volts 2.50 ###############
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Working circuit in room light | A mid-range reading |
| Covered | Close to zero |
| Bright torch | Near full scale |
| Resistor to 5 V | Always near 1023 |
| Ground end of the resistor missing | Readings wander |
If it does not work
Readings never change
The LDR may not be in the divider, so check both legs.
Always zero
Check the LDR leg to 5 V.
Always full
Check the resistor goes to GND, not 5V.
Numbers noisy
Keep the wires short and check the ground end.
Meter and sketch disagree
Check the meter is on DC volts and the probe is on A0.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the light sensor fault hunt?
Arduino Nano, LDR Photoresistor, Resistor 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the light sensor fault hunt take to build?
About 50 minutes for a beginner maker, in 7 steps.
How do I know the light sensor fault hunt works?
Working circuit in room light: A mid-range reading. Covered: Close to zero. Bright torch: Near full scale.
Readings never change: what should I check?
The LDR may not be in the divider, so check both legs.
Always zero: what should I check?
Check the LDR leg to 5 V.
Always full: what should I check?
Check the resistor goes to GND, not 5V.
Numbers noisy: what should I check?
Keep the wires short and check the ground end.
