Skip to content

Instantly share code, notes, and snippets.

@yeffrimic
Last active May 15, 2017 06:21
Show Gist options
  • Save yeffrimic/3b3c438e3103a4e3e3a1e8c497dbe8aa to your computer and use it in GitHub Desktop.
Save yeffrimic/3b3c438e3103a4e3e3a1e8c497dbe8aa to your computer and use it in GitHub Desktop.
int salida1 = 10;
int salida2 = 10;
boolean cerrado=false;
boolean abierto=true;
int tiempoCerrado=5000;
void setup() {
// put your setup code here, to run once:
pinMode(salida1,OUTPUT);
pinMode(salida2,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int ldrStatus=analogRead(A0);
if(ldrStatus <=300){// vamos a cerrar la cortina
if(abierto ==true && cerrado == false){
digitalWrite(salida1,HIGH);
delay(tiempoCerrado);
digitalWrite(salida1,LOW);
cerrado =true;
abierto =false;
return;
}
}else{
if(abierto ==false && cerrado == true){
digitalWrite(salida2,HIGH);
delay(tiempoCerrado);
digitalWrite(salida2,LOW);
abierto =true;
cerrado =false;
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment