#define LDR 35
#define red 25
void setup () {
pinMode (red, OUTPUT);
pinMode (LDR, INPUT);
Serial.begin (115200);
}
void loop () {
int ldr = analogRead(LDR);
Serial.print("A luminosidade em luxes equivale a: ");
float luxes = (0.519*ldr);
Serial.println(luxes);
if (ldr >= 1500){
digitalWrite(red,1);
Serial.print("LUZ LIGADA\n\n");
delay(2000);
}
else if (ldr < 1500){
digitalWrite(red,0);
Serial.print("LUZ DESLIGADA\n\n");
delay(2000);
}
}