8 may 2016

Simple Automated Light Control Arduino Implementation - SALCAI_0.2.1


// Simple Automated Light Control Arduino Implementation 
// SALCAI_0.2.1 


int lightSensor = A2;
int lightLevel;
int led = 13;
int rele = 12;

void setup() {
  pinMode(rele, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(lightSensor, INPUT);
  Serial.begin(9600);
}

void loop(){

  lightLevel=analogRead(lightSensor);
  Serial.println(lightLevel);
  {
    if(lightLevel > 560)
    {digitalWrite(led, HIGH);
   digitalWrite(rele, HIGH);
  
    delay(24560);
    }
   

    if(lightLevel <= 560)
   
  
    {digitalWrite(led, LOW);
    digitalWrite(rele,LOW);
    }
  }
 
  delay(120);
 
}


// Creative Commons Licence
// Luis Rodriguez