#include <Wire.h>
#include <LiquidCrystal.h>
const int trigPin = 9;
const int echoPin =10;
const int ledPin = 13;
LiquidCrystal_12C lcd(0x27, 16, 2);
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledPin, OUTPUT);
lcd.init();
lcd.backlight();
Serial.begin(9600);
}
void loop() {
// Read ultrasonic sensor distance
long duration = pulseIn(echoPin, HIGH);
float distance = duration * 0.034 / 2;
// Check if object is within 10cm range
if (distance <= 10) {
// Turn on LED
digitalWrite(ledPin, HIGH);
}