TEMA 9
PIR LDR
const int led=8;
const int pir=2;
int ldr=A0;
int led1=10;
void setup() {
pinMode (led,OUTPUT);
pinMode (pir,INPUT);
pinMode (9,OUTPUT);
pinMode(led1,OUTPUT);
pinMode(ldr,INPUT);
Serial.begin(9600);
}
void loop() {
delay(1000);
if(digitalRead(pir)==HIGH && (analogRead (ldr) <=600))
{
digitalWrite(led1,HIGH);
digitalWrite (led,HIGH);
digitalWrite (9,HIGH);
Serial.println("Intruso Detectado");
delay(300);
}
else{
digitalWrite(led,LOW);
digitalWrite (9,LOW);
digitalWrite(led1,LOW);
Serial.println("Sin Peligro");
}
}
PIR LDR
const int led=8;
const int pir=2;
int ldr=A0;
int led1=10;
void setup() {
pinMode (led,OUTPUT);
pinMode (pir,INPUT);
pinMode (9,OUTPUT);
pinMode(led1,OUTPUT);
pinMode(ldr,INPUT);
Serial.begin(9600);
}
void loop() {
delay(1000);
if(digitalRead(pir)==HIGH && (analogRead (ldr) <=600))
{
digitalWrite(led1,HIGH);
digitalWrite (led,HIGH);
digitalWrite (9,HIGH);
Serial.println("Intruso Detectado");
delay(300);
}
else{
digitalWrite(led,LOW);
digitalWrite (9,LOW);
digitalWrite(led1,LOW);
Serial.println("Sin Peligro");
}
}
Comentarios
Publicar un comentario