1. Prepare the breadboard power rails
Connect the Arduino 5V pin to the positive rail and GND to the negative rail. Keep power disconnected while placing the remaining components.
Builder tip: Use consistent wire colors—red for 5V and black for ground—to make troubleshooting easier.
2. Build the light sensor
Place the photoresistor from 5V to a free row. Connect that row to A0, then place the 10 kΩ resistor from the same row to ground.
3. Connect the LED
Connect digital pin 9 to the LED anode through the 220 Ω resistor. Connect the shorter cathode leg to ground.
Builder tip: The longer LED leg is normally the positive anode. The flat edge of the LED body marks the cathode.
4. Upload the sketch
Connect the board by USB, select the correct board and port in the Arduino IDE, and upload the code shown below.
5. Test and calibrate
Cover the photoresistor with your hand. If the LED switches at the wrong light level, watch the Serial Monitor values and adjust the lightThreshold constant.