#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensor=6;
int i=0;
void setup()
{
lcd.begin(16, 2);
pinMode(6,INPUT);
}
void loop()
{
i=digitalRead(sensor);
if(i==HIGH)
{
lcd.clear();
lcd.write("HIGH");
}
else
{
lcd.clear();
lcd.write("LOW");
}
delay(1000);
}
I have used a digital ir sensor. if the output of sensor is high then the lcd should display high otherwise it should display low. but i am getting LOW followed by HIGH after every second irrespective of the state of ir sensor. please solve this problem of mine