Thursday, 30 April 2020

Interfacing of Multiple Ultrasonic Sensors (3 HC-SR04 ) With Arduino


Please Subscribe For More Project Videos --► http://bit.ly/29vPrS9
Block diagram:
Please Subscribe For More Project Videos --► http://bit.ly/29vPrS9
HC-SR04 ULTRASONIC SENSOR:
SCHEMATIC DIAGRAM:

FINAL SOFTWARE CODE:
----------------------------------------
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
#define trigPin1 A0
#define echoPin1 A1
#define trigPin2 A2
#define echoPin2 A3
#define trigPin3 A4
#define echoPin3 A5
int ALARM = 7;
long duration, distance, FIRSTSensor,SECONDSensor,THIRDSensor;
void setup()
{
lcd.begin(16,2);
Serial.begin (9600);
lcd.clear(); 
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);
pinMode(trigPin3, OUTPUT);
pinMode(echoPin3, INPUT);
pinMode(ALARM, OUTPUT);
digitalWrite(ALARM, LOW);
 lcd.setCursor(0,0);lcd.print("Interfacing ");
lcd.setCursor(0,1);lcd.print("of Multiple ");
delay(3000);lcd.clear();  
lcd.setCursor(0,0);lcd.print("3 HC - SR04 ");
lcd.setCursor(0,1);lcd.print("Ultrasonic  ");
delay(3000);lcd.clear();
lcd.setCursor(0,0);lcd.print("SensorS With ");
lcd.setCursor(0,1);lcd.print("Arduino ");
delay(3000);lcd.clear();
}

void loop() 
{
/////////////////////////////////////////////////////// 
SonarSensor(trigPin1, echoPin1);
FIRSTSensor = distance;
SonarSensor(trigPin2, echoPin2);
SECONDSensor = distance;
SonarSensor(trigPin3, echoPin3);
THIRDSensor = distance;
/////////////////////////////////////////////////////////////
digitalWrite(ALARM, LOW);
//////////////////////////////////////////////////////////////////////////////////////
Serial.print("S1:");Serial.println(FIRSTSensor); delayMicroseconds(10);
Serial.print("S2:");Serial.println(SECONDSensor);delayMicroseconds(10);
Serial.print("S3:");Serial.println(THIRDSensor); delayMicroseconds(10);
///////////////////////////////////////////////////////////////////////////////////////
lcd.setCursor(0,0);lcd.print("S1:");lcd.setCursor(4,0);lcd.print(FIRSTSensor);
lcd.setCursor(9,0);lcd.print("S2:");lcd.setCursor(12,0);lcd.print(SECONDSensor);
lcd.setCursor(0,1);lcd.print("S3:");lcd.setCursor(4,1);lcd.print(THIRDSensor);
delay(1000);lcd.clear();
///////////////////////////////////////////////////////
if((FIRSTSensor >= 10) & (FIRSTSensor <= 50)) 
{digitalWrite(ALARM, HIGH);delay(500);}
///////////////////////////////////////////////////////
if((SECONDSensor >= 10) & (SECONDSensor <= 50)) 
{digitalWrite(ALARM, HIGH);delay(500);}
///////////////////////////////////////////////////////
if((THIRDSensor >= 10) & (THIRDSensor <= 50)) 
{digitalWrite(ALARM, HIGH);delay(500);}
///////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////
void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
}
------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Please Subscribe For More Project Videos --► http://bit.ly/29vPrS9 Slice--►http://www.svskits.in/ blog --►http://www.svskit.com/ site --►http://www.svsembedded.com/ ------------------------------------------------------------------------- ✽ FOLLOW ME! Twitter: --►https://bit.ly/2Vms5Eq Facebook: --►https://bit.ly/2wyQkH0 linkedin: --►https://bit.ly/3ekwccQ flickr: --►http://bit.ly/29nunKE Pinterest: --►http://bit.ly/29A4Ocq Thumbs up if you want to see more projects! *What would you like to see next?! Links: Android projects:--► http://bit.ly/29nlAs5 GSM Based Projects:--► http://bit.ly/29nA0Y7 Bluetooth Based Projects:--► http://bit.ly/29G93nV women safety projects:--► http://bit.ly/29BEhNv Touchscreen+Restaurant:--► http://bit.ly/29tB2oz LabVIEW Projects:--► http://bit.ly/29IlY8W Agriculture Projects:--►http://bit.ly/29ATa0z Touch Screen Home Automation:--►http://bit.ly/29po3RN IOT Based Projects:--►http://bit.ly/29Cai60 ♥ Business Email:--► info@svsembedded.com, Email:--► svsembedded@gmail.com *Feel free to send me a mail about u r project abstract/synopsis! :]





No comments:

Post a Comment

A Novel Approach for Vehicular Accident Detection and Rescue Alert Syste...

A Novel Approach for Vehicular Accident Detection and Rescue Alert System using IoT | A Novel Approach to Automatic Road-Accident Detection ...