Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
Ultrasonic Sensor Based Motion Detection System
Just Do Electronics
August 20, 2022
Circuit Diagram :-
Component List
1. Arduino Nano
2. 16x2 LCD Display
3. 10k Potentiometer
4. Buzzer
Code :-
// Prateek //www.prateeks.in const int trigPin = 4; const int echoPin = 5; const int buzzerPin = 6; long duration; int distance; long distancemm; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(buzzerPin, OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance= duration*0.034/2; distancemm = distance*10+30; if (distancemm <= 50) { for (int i=0; i <= 50; i++){ digitalWrite(buzzerPin, HIGH); delay(10); } } else if (distancemm >= 121) { digitalWrite(buzzerPin, LOW); } else { //digitalWrite(buzzerPin, HIGH); } // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); Serial.print("Distance: "); Serial.print(distancemm); Serial.println("mm"); delay(250); }
With Lcd Code :-
//Prateek //www.prateeks.in #include
#include
LiquidCrystal lcd(12, 11, 10, 9, 8, 5); #define trigPin 4 #define echoPin 5 int Buzzer = 6; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(Buzzer, OUTPUT); Serial.begin(9600); lcd.begin(16, 2); lcd.clear(); lcd.setCursor(0, 0); // column, row lcd.print(" Welcome To Our "); lcd.setCursor(0, 1); // column, row lcd.print(" Project"); delay(2000); lcd.clear(); } void loop() { long time_duration, distance_in_cm; digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); time_duration = pulseIn(echoPin, HIGH); distance_in_cm = time_duration / 29 / 2; Serial.print(distance_in_cm); Serial.println(" cm"); if (distance_in_cm <= 10) { lcd.clear(); Serial.println("Motion detected!"); lcd.setCursor(0, 0); // column, row lcd.print(" Motion Detected!"); digitalWrite(Buzzer, HIGH); delay(2000); } else { lcd.clear(); lcd.setCursor(0, 1); // column, row lcd.print("Nothing Detected!"); digitalWrite(Buzzer, LOW); } delay(500); }
Video :-
0 Comments
Newer
Older
ESP32 Interfacing With LDR Sensor
ESP32 Led Blink With Push Button
IoT Based Patient Health Monitoring System Using Blynk App
Ultrasonic Sensor as a Counter with Arduino
Esp32 Cam Based Face Unlock
Sign Language to Speech Conversion using Arduino With Flex Sensor
MLX90614 Non-Contact Infrared Thermometer With Arduino
ESP32 Interfacing Potentiometer
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
Measure CO2 Level in Air Using Arduino
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
0 Comments