Easier Approach to Electronic Projects

Light Sensor using Arduino

Connect one pin of LDR to 5v and another pin to A0 input.This is a Light sensor using LDR and Arduino, you can make it either Shadow detector or light detector by simply changing the code given below.

Connect one pin of 10k resistor to GND and another pin to A0 input
The code below makes the arduino as a Shadow detector, to make it light detector you change the Condition statements, If Else part :) change different things and get different outputs.. Enjoy
 Just copy and paste this code into your arduino program and upload it.

Here are some best prices on Arduino UNO alone and with Kit


int LDR = 0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0
int LDRValue = 0;      //that’s a variable to store LDR values
int light_sensitivity = 500;    //This is the approx value of light surrounding your LDR
void setup()
    Serial.begin(9600);          //start the serial monitor with 9600 buad
    pinMode(13, OUTPUT);     //we mostly use 13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled
void loop()
    LDRValue = analogRead(LDR);      //reads the ldr’s value through LDR 
    Serial.println(LDRValue);       //prints the LDR values to serial monitor
    delay(50);        //This is the speed by which LDR sends value to arduino
    if (LDRValue < light_sensitivity) 
        digitalWrite(13, HIGH);
        digitalWrite(13, LOW);

Did it work? If it did, you can thank me back by donating whatsoever amount possible. My website is a personal initiative for education and development, and to provide a user-friendly experience I do not allow any sort of monetizing adds on my website. Your donation is very precious for the future development of Rookie Electronics. Thank you!

Click this donate button which will take you to safe PayPal window where you can donate Rookie Electronics.


Read more:
Clap Switch Circuit (2)-002 copy
Clap Switch Circuit

This is a sound sensitive circuit, When sound is produced it is changed into electric energy through condenser mic and...

DC Generator
Simple DC Generator

This little project is one which I made when I was in grade 7 in High School, and I won...

Contact Me

Please fill in the following fields and click submit. Your messages are received by me and I try my best...