LIGHT SENSITIVE LED
OVERVIEW
Wouldn’t it be cool if we could eliminate darkness? In this arduino project,we are going to build a project that focuses on eliminating darkness.This involves an LDR, an led and arduino.The LDR triggers the led on when there is insufficient light in a room.
DETAILS
In order to detect the intensity of light,we use a sensor called an LDR (light dependent resistor).
This works by sensing the intensity of light in its environment.You can purchase an LDR sensor at https://www.inventelectronics.com/product/light-dependent-resistor/.The LDR gives out an analog voltage when connected to VCC (5V), which varies in magnitude in direct proportion to the input light intensity on it. That is, the greater the intensity of light, the greater the corresponding voltage from the LDR will be. Since the LDR gives out an analog voltage, it is connected to the analog input pin on the Arduino. The Arduino, with its built-in ADC (analog-to-digital converter), then converts the analog voltage (from 0-5V) into a digital value in the range of (0-1023). When there is sufficient light in its environment or on its surface, the converted digital values read from the LDR through the Arduino will be in the range of 800-1023.This can be applied our home lighting systems,street lights and others.
LDR
COMPONENTS
FRITZ
CODE
int LDRpin= A0; // pin where we connected the LDR and the resistor int ledpin=7; int LDRValue = 0; // result of reading the analog pin void setup() { Serial.begin(9600); // sets serial port for communication pinMode(ledpin,OUTPUT); } void loop() { LDRValue = analogRead(LDRpin); // read the value from the LDR Serial.println(LDRValue); // print the value to the serial port delay(100); // wait a little if (LDRValue <100){ digitalWrite(ledpin,HIGH); } else { digitalWrite(ledpin,LOW); } }
PIC
CONCLUSION
We hope you enjoyed the tutorial and this little lesson will purport you into great levels. Enjoy yourself in electronics .for more tutorials and questions, please leave your comments in the comment area. See other components on the site www.inventelectronics.com. Inspiring ingenuity.