Tarantula3DIYables
Published

Using An LDR Sensor With Arduino

Wouldn’t it be really cool if whenever a room gets dark, a light bulb automatically turns ON and eliminates the darkness?

BeginnerFull instructions provided1 hour175,299
Using An LDR Sensor With Arduino

Things used in this project

Story

Read more

Schematics

Assembly

Code

The Code

Arduino
const int ledPin = 13;

const int ldrPin = A0;

void setup() {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

pinMode(ldrPin, INPUT);

}

void loop() {

int ldrStatus = analogRead(ldrPin);

if (ldrStatus <= 200) {

digitalWrite(ledPin, HIGH);

Serial.print("Its DARK, Turn on the LED : ");

Serial.println(ldrStatus);

} else {

digitalWrite(ledPin, LOW);

Serial.print("Its BRIGHT, Turn off the LED : ");

Serial.println(ldrStatus);

}

}

Credits

Tarantula3
68 projects • 85 followers
There were 1000+ sperms but I was the fastest one..
DIYables
0 projects • 81 followers
I would like to invite you to join and add your projects to DIYables platform https://www.hackster.io/diyables

Comments