Hello everyone;
I am Amey, welcome to my channel
Today, I am building another cool project which is Measuring tape with the help of ultrasonic sensor and Arduino. So lets' make it
Components: -
1. Arduino Uno
2. ultrasonic sensor (HC-SR04)
3. 16 x 2 lcd
4. I2C module for LCD (Optional)
5. Laser
6. 7805
7. 9v Battery
Working: -
This project is really simple. I
am using an ultrasonic sensor (HC-SR04) which work on principle of doppler
effect
Ultrasonic sensors work by emitting sound waves at a frequency
too high for humans to hear. They then wait for the sound to be reflected back,
calculating distance based on the time required. This is similar to how radar
measures the time it takes a radio wave to return after hitting an object
Circuit
Diagram: -
#define trigger 18
#define echo 19
LiquidCrystal lcd(2,3,4,5,6,7);
float time=0,distance=0;
void setup()
{
lcd.begin(16,2);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
lcd.print(" Ultra sonic");
lcd.setCursor(0,1);
lcd.print("Distance Meter");
delay(2000);
}
void loop()
{
lcd.clear();
digitalWrite(trigger,LOW);
delayMicroseconds(2);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
delayMicroseconds(2);
time=pulseIn(echo,HIGH);
distance=time*340/20000;
lcd.clear();
lcd.print("Distance:");
lcd.print(distance);
lcd.print("cm");
lcd.setCursor(0,1);
lcd.print("Distance:");
lcd.print(distance/100);
lcd.print("m");
delay(1000);
}
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define trigger 18
#define echo 19
LiquidCrystal_I2C lcd(
0x27,
16,
2);
lcd.begin()
;
float time=0,distance=0;
void setup()
{
lcd.begin(16,2);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
lcd.print(" Ultra sonic");
lcd.setCursor(0,1);
lcd.print("Distance Meter");
delay(2000);
}
void loop()
{
lcd.clear();
digitalWrite(trigger,LOW);
delayMicroseconds(2);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
delayMicroseconds(2);
time=pulseIn(echo,HIGH);
distance=time*340/20000;
lcd.clear();
lcd.print("Distance:");
lcd.print(distance);
lcd.print("cm");
lcd.setCursor(0,1);
lcd.print("Distance:");
lcd.print(distance/100);
lcd.print("m");
delay(1000);
}
video
Comments
Post a Comment