HOW TO MAKE AROMATIC DARK LIGHT SENSOR BY USING ARDUINO AND LDR WITH CODE AND CIRCUIT DIAGRAM



WHO IT IS WORK

             This system works by sensing the intensity of light in its environment. The sensor that can be used to detect light is an LDR. It's inexpensive, and you can buy it from any local electronics store or online. 

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.

ARDUINO LDR SENSOR CONNECTION CIRCUIT DIAGRAM

THE CODE FOR ARDUINO DARK LIGHT SENSOR


//set pin numbers
//const won't change
const int ledPin = 8;   //the number of the LED pin
const int ldrPin = A0;  //the number of the LDR pin


void setup() {

  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  //initialize the LED pin as an output
  pinMode(ldrPin, INPUT);   //initialize the LDR pin as an input
}

void loop() {

  int ldrStatus = analogRead(ldrPin);   //read the status of the LDR value

  //check if the LDR status is <= 300
  //if it is, the LED is HIGH

   if (ldrStatus <=300) {
  digitalWrite(ledPin , HIGH );

                  //turn LED on
    Serial.println("LDR is DARK, LED is ON");
    
   }
  else {

    digitalWrite(ledPin, LOW);          //turn LED off
    Serial.println("---------------");
  }



  
}



copy this code and past in arduino ID 
plz subscribe my youtube channel















Comments

  1. I really love it and amazing information in this blog. it's really good and great information well done. LDR Sensor in Mumbai.

    ReplyDelete
  2. The cnnection of two wire connected two switch then connected to breadbord or arduino

    ReplyDelete

  3. exit status 1
    Error compiling for board Arduino/Genuino Uno.

    how the solutiom

    ReplyDelete

Post a Comment

Popular posts from this blog