Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE
Soo this is one is a cool project. It’s a distance sensor!
Demo:
This is how my project turned out:
Things Required:
- Arduino UNO
- Jumper Wires
- 16×2 LCD Screen
- HC-SR04 Sensor
- 10k potentiometer
- Arduino IDE on computer
Reference Material:
Code:
View on/ Download from Github: (LINK)
#include<LiquidCrystal.h>
int rs=7;
int en=6;
int d4=2;
int d5=3;
int d6=4;
int d7=5;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int trigpin=12;
int echopin=11;
int traveltime;
int dt=25;
int distance;
void setup() {
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
}
void loop() {
digitalWrite(trigpin, LOW);
delayMicroseconds(dt);
digitalWrite(trigpin, HIGH);
delayMicroseconds(dt);
digitalWrite(trigpin, LOW);
traveltime= pulseIn(echopin, HIGH);
distance= traveltime*(0.034/2);
delay(300);
lcd.setCursor(0,0);
lcd.print("Distance= ");
lcd.print(distance);
lcd.print(" cm");
}
Stay Tuned for upcoming posts on Arduino Projects! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!
Happy Learning!!
