TEMA 7
LDR
int ldr=A0;
int led=10;
int relay=2;
void setup() {
pinMode(led,OUTPUT);
pinMode(relay,OUTPUT);
pinMode(ldr,INPUT);
}
void loop() {
if (analogRead (ldr) <=790){
digitalWrite(relay,HIGH);
digitalWrite(led,HIGH);
}
else{
digitalWrite(relay,LOW);
digitalWrite(led,LOW);
}
}
LDR
int ldr=A0;
int led=10;
int relay=2;
void setup() {
pinMode(led,OUTPUT);
pinMode(relay,OUTPUT);
pinMode(ldr,INPUT);
}
void loop() {
if (analogRead (ldr) <=790){
digitalWrite(relay,HIGH);
digitalWrite(led,HIGH);
}
else{
digitalWrite(relay,LOW);
digitalWrite(led,LOW);
}
}
Comentarios
Publicar un comentario