Fatemeh NabidoustMohammad Nabidoust
Published

🔰How to make a Control Light sensor using LDR

How to make a Control Light sensor using LDR

ExpertFull instructions provided151
🔰How to make a Control Light sensor using LDR

Things used in this project

Story

Read more

Schematics

elec_astro_382gnDU6HC.pdf

Code

‌How to make a Control Light sensor using LDR

Arduino
#include <Wire.h>             
#include <LiquidCrystal_I2C.h> 


LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);       
  pinMode(13, OUTPUT);      
  
 
  lcd.init();                
  lcd.backlight();           
  lcd.setCursor(0, 0);       
  lcd.print("Light Sensor");
  delay(2000);               
}

void loop() {
  float sensorValue = analogRead(A0);
  // Reads the analog input ranging from 0 to 1023
  Serial.println(sensorValue);        
  
  
  if(sensorValue<=400)
  {
    digitalWrite(13, HIGH);
  }
  else
    digitalWrite(13, LOW);
  
 
  lcd.clear();                 
  lcd.setCursor(0, 0);          
  lcd.print("Light: ");        
  lcd.print(sensorValue, 0);    
  lcd.setCursor(0, 1);          
  if(sensorValue<=400)
  {
    lcd.print("Dark");          
  }
  else
  {
    lcd.print("Bright");       
  }
  delay(500);                 
}

Credits

Fatemeh Nabidoust
8 projects • 6 followers
•Founder & CEO : PishgamanIEA Co,LTD •(Electronic, Computer Science, Aerospace) Engineer •Senior Programmer
Mohammad Nabidoust
4 projects • 2 followers
STM32xx projects Design, Circuit PCB Design, Medical, Industrial, Power supply

Comments