Anjali Shaw
Published © GPL3+

Ldr sensor

Afraid of darkness. Here, is a way to get out of it. Go further..........to look into the project.

BeginnerFull instructions provided30 minutes71
Ldr sensor

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
LED (generic)
LED (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 221 ohm
Resistor 221 ohm
×1
9V battery (generic)
9V battery (generic)
×1
9V Battery Clip
9V Battery Clip
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

screenshot_2020-05-24_at_12_26_46_pm_emgdaopSMs.png

Schematics

Make the connections as per schematic diagram.

Code

The Project code.

Arduino
The code for project is given below.
you have to make the connections as per code.
I would like to suggest you guys that you should write the code and must not just copy paste it.
You can have a look to the value recorder in arduino monitor just go to tools and then Serial Monitor.
Always remember to put the rate same.Here, I'm going with baud rate 9600 and so I will set the rate of Serial Monitor also to 9600.
const int ledPin = 8;
const int ldrPin = A0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
Serial.print(ldrStatus);
if (ldrStatus <= 70) {
digitalWrite(ledPin, HIGH);
Serial.print("   Turning ON the LED : ");
Serial.println(ldrStatus);
} 
else {
digitalWrite(ledPin, LOW);
Serial.print("    Turning OFF the LED : ");
Serial.println(ldrStatus);
}
}

Credits

Anjali Shaw

Anjali Shaw

8 projects • 0 followers

Comments