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.

BeginnerShowcase (no instructions)12 minutes8,166
Automatic Brightness Sensor

Things used in this project

Story

Read more

Schematics

Photoresistance

I use voltage divider to check brightness

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

8 projects • 14 followers

Comments