-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lectura LUX
47 lines (44 loc) · 878 Bytes
/
Lectura LUX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int ldr = A0;
float lectura;
int ledbajo=5;
int ledalto=6;
int led=2;
void setup()
{
pinMode(ldr,NPUT);
Serial.begin(9600);
pinMode(ledbajo,OUTPUT);
pinMode(ledalto,OUTPUT);
pinMode(led,OUTPUT);
}
void loop()
{
lectura=analogRead(ldr);
float volt=lectura*0.0009765625;
float LUX=120*volt;
LUX=map(LUX,0,120,0,80);//(lectura,MinimoInicial,MaxInicial,miniSalida,Max.Salida)
Serial.print(LUX);
Serial.println(" lux")
if(LUX<=60)
{
Serial.println("hAY POCA LUZ");
digitalWrite(ledbajo,HIGH);
digitalWrite(ledalto,LOW);
digitalWrite(led,LOW);
}
if(LUX>=70)
{
Serial.println("MUCHA LUZ !!!");
digitalWrite(ledalto,HIGH);
digitalWrite(ledbajo,LOW);
digitalWrite(led,LOW);
}
if(LUX > 60 && LUX <70)
{
Serial.println("Condiciones normales");
digitalWrite(led,HIGH);
digitalWrite(ledalto,LOW);
digitalWrite(ledbajo,LOW);
}
delay(100);
}