0% found this document useful (0 votes)
3 views1 page

TOPIC1

Uploaded by

june cadayona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

TOPIC1

Uploaded by

june cadayona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <LiquidCrystal_I2C.

h>

LiquidCrystal_I2C lcd(0x27, 16, 2);


int trigPin = A11;
int echoPin = A12;
float duration, distance_foot, distance_inch;
const float limit_distance_foot =2;

void setup() {
lcd.begin();
lcd.backlight();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);


distance_foot = duration* 0.001344 / 2;
distance_inch = distance_foot * 12 ;

lcd.clear();

if (distance_foot >= limit_distance_foot) {


lcd.setCursor(0, 0);
lcd.print("LIMIT REACHED");
} else {
lcd.setCursor(0, 0);
lcd.print("FOOT: ");
lcd.print(distance_foot);

lcd.setCursor(0, 1);
lcd.print("INCH: ");
lcd.print(distance_inch);
}

delay(500);
}

You might also like