RoboCircuits
Published

Ultimate Object Sensing

Sense the distance of any object in front of it.

ExpertShowcase (no instructions)499
Ultimate Object Sensing

Things used in this project

Story

Read more

Schematics

untitled_sketch_LOQyRdDsQO.fzz

Code

Arduino distance sensor code

Arduino
Just Copy this code and upload it in ur adruino
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,44,3,2);
const int trigPin = 10;
const int echoPin = 9;
long duration;
int distance;
void setup()
{
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  lcd.begin(16,2);
}
void loop()
{
  digitalWrite(trigPin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(2);
  digitalWrite(trigPin,LOW);
  Duration=pulseIn(echoPin,HIGH);
  Distance=Duration*0.034/2;
  lcd.print("Distance=");
  lcd.print(Distance);
  delay(10);
  lcd.clear();
}

Credits

RoboCircuits

RoboCircuits

3 projects • 3 followers
RoboCircuits is a YouTube channel working on making cool arduino projects and tutorials.

Comments