Introduction
LDR - Light Dependent Resistor
In this article, I'll show you how to work with LDR to sense the light levels, measure those levels with the Arduino Uno, and print the value to the serial port.
Required Components:
- Arduino Uno
- LDR
- Bread Board
- led
Connections:

- Led Anode pin to Arduino digital pin.
- Led Cathode pin to Gnd.
Programming
- int LDR=A0;
- int led=13;
- int ldr reading=0;
- void setup()
- {
- pinMode(led,OUTPUT);
- Serial.begin(9600);
- }
- void loop()
- {
- ldr reading=analogRead(LDR);
- if(value < 800)
- {
- digitalWrite(led,HIGH);
- }
- else
- {
- digitalWrite(led,LOW);
- }
- Serial.println(ldr reading);
- delay(200);
- }
Explanation
Initialize the value to the LDR to the Analog Pin and set value "0." In setup() function we want to set the Baud Rate as 9600 and in the loop() function we want to make the condition to the LDR; such as, first we want to read the Analog Pin value from the Arduino board. If the value is less than 800, the led will be ON, else the led will be in the OFF condition, and then print the value in the serial monitor.
Output:

Read more articles on Arduino:


Rodrigo SantosPosted Jul 11, 2020, 11:29 AM EDT
Thank you so much!
Kumaresh RajalingamPosted Feb 16, 2016, 5:01 AM EST
Thank u Raja sir
Kumaresh RajalingamPosted Feb 16, 2016, 5:01 AM EST
Thanks u Raja sir
Kumaresh RajalingamPosted Feb 16, 2016, 5:01 AM EST
Thanks sibeesh sir
Kumaresh RajalingamPosted Feb 16, 2016, 5:01 AM EST
Thanks Mohammed sir
Raja TPosted Feb 14, 2016, 10:05 PM EST
Nice,Thanks for sharing
Sibeesh VenuTOP 100Posted Feb 14, 2016, 7:36 PM EST
Nice Share
Mohammed IbrahimPosted Feb 14, 2016, 6:27 PM EST
nice
Kumaresh RajalingamPosted Feb 12, 2016, 10:50 PM EST
Thank you santha kumar sir
Kumaresh RajalingamPosted Feb 12, 2016, 10:50 PM EST
Thank u Shubham Kumar sir
Santhakumar MunuswamyPosted Feb 12, 2016, 9:58 PM EST
Thanks for nice share
Shubham KumarPosted Feb 12, 2016, 8:15 PM EST
nice
Kumaresh RajalingamPosted Feb 12, 2016, 7:32 PM EST
Thanks Pramod Sir
Pramod ThakurPosted Feb 12, 2016, 7:31 PM EST
Nice..
Sr KarthigaPosted Feb 12, 2016, 2:42 PM EST
Good one