#include <LiquidCrystal.h>
// RS, E, D4, D5, D6, D7
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// Pinos
int ldr = A0;
int led = 7;
void setup()
{
lcd.begin(16, 2);
pinMode(led, OUTPUT);
}
void loop()
{
// Leitura do LDR
int valorLDR = analogRead(ldr);
// Mostra no display
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Valor LDR:");
lcd.setCursor(0, 1);
lcd.print(valorLDR);
// Condicao
if (valorLDR > 400)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
delay(500);
}