Showing posts with label measure. Show all posts
Showing posts with label measure. Show all posts

Thursday, October 27, 2016

PROGRAM TO MEASURE DISTANCE BY ULTRASONIC WITH ARDUINO

PROGRAM TO MEASURE DISTANCE BY ULTRASONIC WITH ARDUINO


#define trigPin 12
#define echoPin 2
#include <LiquidCrystal.h>
#define D4 6
#define D5 7
#define D6 8
#define D7 9
#define RS 11
#define EN 12
float tempreture;
LiquidCrystal lcd(12, 11, 6, 7, 8, 9);
void setup()
{
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop() {
  float duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Distance; ");
  lcd.setCursor(10,0);
  lcd.print(distance);
  delay(100);
}









Available link for download

Read more »