Achraf Oukheir
Published

Automatic Brightness Sensor

This small tool checks brightness, and if there is fog or night out, will turn on without human action or worry.

EasyShowcase (no instructions)12 minutes2,400
Automatic Brightness Sensor

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Photo resistor
Photo resistor
×1
LED (generic)
LED (generic)
×1
Grove - Relay
Seeed Grove - Relay
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Photoresistance

I use voltage divider to check brightness
Photoresistor tq4nxi9lid

Code

Code

Arduino
//OUKHEIR Achraf
const int LumPin = A0;    // select the input pin for Senosr
const int RidPin1 = 9;      // select the pin for Rideaux
const int RidPin2 = 8;      // select the pin for Rideaux
int LumValue = 0;  // variable to store the value coming from the sensor
int SiLum =0 ; //Etat rideau 0
void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(RidPin1, OUTPUT);
  pinMode(LumPin, INPUT);
  Serial.begin(9600);
}

void loop() {
 Serial.print("Luminoste value = ");
Serial.println(ReadLum());

SiLum= LightDark();
if(SiLum==1){
   Rideaux1(1);
}else {
  Rideaux1(0);
}

delay(1000);
}


//fonction de Luminosite read
int ReadLum(){
LumValue =analogRead(LumPin);
delay(100);
  return  LumValue;
}

//fonction de check Luminosite
int LightDark(){
 //check ifDark or light
  if ( LumValue  < 28) {
    // turn  on:
    digitalWrite(RidPin1, HIGH);
    return 1; 
  } else  if ( LumValue  >33){
    // turn  off:
    digitalWrite(RidPin1, LOW);
  
  return 0;
  }
  
}

//fonction de Rideau
int Rideaux1(int act){
  if(act==1){
    digitalWrite(RidPin1, HIGH);
  return 1;
  }else{
  digitalWrite(RidPin1, LOW);
  return 0;
  }
  }
//OUKHEIR Achraf

Credits

Achraf Oukheir

Achraf Oukheir

6 projects • 8 followers

Comments

Add projectSign up / Login