Hello everyone I'm Manitesla .In this post, you will learn how to use an LDR or Light Dependent resistor to turn on and off another circuit or a LED.
This project would help you in understanding how automatic day/ night activated LEDs work. Do you guys want to know how whenever a room gets dark, a light bulb automatically turns ON and the darkness disappears. In this very simple project, ill teach you everything you need to know to make your own day/light sensor.
A LDR (Light Dependent Resistor) or a photo resistor is a photo conductive sensor. It is a variable resistor and changes its resistance varies with light intensity. It’s resistance decreases with the intensity of light.
Circuit Diagram:
Arduino Code:
int led= 9; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); pinMode(A0, INPUT); } void loop() { int val = analogRead(A0); Serial.println(val); if (val <= 150) { digitalWrite(led, HIGH);
} else { digitalWrite(led, LOW);
} }
0 comments:
Post a Comment
Ask Something