#include<LiquidCrystal.h>
const int RS = 12, E = 11, D4 = 4, D5 = 5, D6 = 6, D7 = 7;
LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
const int sensotPin = 1;
const int LED = 0;
const int LED2 = 10;
int sensorValue;
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(sensotPin, INPUT);
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED2, HIGH);
sensorValue = digitalRead(sensotPin);
lcd.setCursor(0, 0);
lcd.print("Sensor value : ");
lcd.print(sensorValue);
if(sensorValue == LOW) // low means object detected
{
digitalWrite(LED, HIGH);
lcd.setCursor(0, 1);
lcd.print("object detected");
}
else{
digitalWrite(LED, LOW);
lcd.setCursor(0, 1);
lcd.print("no detect");
}
lcd.clear();
}