Photocell (LDR) Sensor with Arduino

LDR (light depended resistor) or photocell sensor, when the light falls on this sensor resistance across the device gets low otherwise when the light intensity decreases the resistance of photocell increases.

By using this sensor we can measure light intensity or control light operated alarm circuit. To understand the simple operation of this photocell, it is connected with arduino board hence we can receive the sensor value in serial port and the output LED intensity according to sensor value.


Circuit diagram


Arduino Photocell (LDR) Sensor sketch code


int ledPin = 3;
int photocell = 0;

void setup() {
pinMode(ledPin, OUTPUT);

void loop() {

photocell = (analogRead(0)/4); // Divides input 0-1023 to resemble to 0-255

analogWrite(ledPin, photocell);
// The delay can be change to get the desired dimming effect


Components List

S.No Name Quantity
1. Arduino uno 1
2. Photocell (LDR) sensor 1
3. LED 1
4. Resistor 10K Ω 1
5. Connecting wires as required



  1. Builox June 18, 2016 Reply
  2. Buibo June 19, 2016 Reply
    • adminAuthor June 22, 2016 Reply
    • QA Team January 20, 2022 Reply

Add a Comment

Your email address will not be published. Required fields are marked *