www.i4info.org

i4info Provides the best hacking Material. Latest hacking tutorials and tools are available here. It is the best place for hackers.

Latest topics

» Facebook Account Hacked
Today at 10:14 am by ssameer758

» Teen Patti Gold Hack & 3 Patti Chips Code Extra Bonus 2016
Today at 8:31 am by furqansweet73

» BitCoin Wallet stealor New
Wed Dec 07, 2016 7:46 pm by Admin

» Muhammad Shahroze Rashid | Marketing Consultant
Wed Dec 07, 2016 1:48 pm by Admin

» Muhammad Shahroze Rashid | Sharp Mind, Sharp Innovations
Wed Dec 07, 2016 1:47 pm by Admin

» How to design an effective job ad
Wed Dec 07, 2016 1:45 pm by Admin

» Content Marketing | Promotional Video
Fri Dec 02, 2016 2:45 pm by Admin

» How to start an Online Business | Complete Guide
Fri Dec 02, 2016 2:30 pm by Admin

» Zeeshan Bhatti
Wed Nov 30, 2016 3:18 pm by Admin

December 2016

MonTueWedThuFriSatSun
   1234
567891011
12131415161718
19202122232425
262728293031 

Calendar Calendar

Affiliates


free forum

Forumotion on Facebook Forumotion on Twitter Forumotion on YouTubeForumotion on Google+

Visitors Counter


Flag Counter

About Author

Muhammad Shahroze Rashid
i4info
Web Developer
Web Developer & Designer,Researcher and Technical writer. An Information Security Consultant and System Auditor, a keen Security researcher.
samanabad
lahore, Punjab
54000
Pakistan
[email protected]
03064904829
DOB: 05/25/1992
Muhammad Shahroze Rashid
Muhammad Shahroze Rashid is a Web Developer and Designer, Android Developer, InfoGrapher, IT consultant and Researcher
Reviewed by Google
Google
Date published: 01/19/2016
9 / 10 stars
Muhammad Shahroze Rashid
Muhammad Shahroze Rashid Web Developer & Designer,Researcher and Technical writer. An Information Security Consultant and System Audito
samanabad
lahore
Punjab
54000
Pakistan

multiple sonar sensors using arduino

Share

Admin
Admin

Posts : 455
Reputation : 5
Join date : 2014-12-10
Age : 24
Location : Pakistan

multiple sonar sensors using arduino

Post by Admin on Sat Jul 30, 2016 4:28 pm

multiple sonar sensors using arduino

HI EVERY ONE IN THIS POST WE ARE INTERFACING multiple sonar sensors using arduino

THERE ARE 3 SONAR SENSOR

multiple sonar sensors arduino
1 SONAR EACH AND TRIGER CONNCTED TO ARDUINO UNO R3

ARDUINO MEASURE 3 SONAR DISTANE AND SEND ALL VALUES IN SERIAL TERMINAL
WHEN ANY SONAR MEASURE DISTANCE LESS THEN 10CM  THEN LED ON

multiple sonar sensors using arduino  code

multiple sonar sensors arduino

 

#define trigPin 12
#define echoPin 11

#define trigPin2 10
#define echoPin2 9

#define trigPin3 8
#define echoPin3 7

#define led1   2
#define led2  3
#define led3  4

long duration, distance;
long duration2, distance2;
long duration3, distance3;
long duration4, distance4;

bool newData = false;
unsigned long chars;
unsigned short sentences, failed;

void setup()
{
Serial.begin(9600);

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

pinMode(trigPin2, OUTPUT);
pinMode(echoPin2, INPUT);

pinMode(trigPin3, OUTPUT);
pinMode(echoPin3, INPUT);

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);

}

void loop()
{
get_sonar();
get_sonar2();
get_sonar3();

delay(300);

}

void get_sonar(){
digitalWrite(trigPin, LOW);  // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
//  delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
Serial.print("s1=");
Serial.print(distance);
Serial.print("cm           ");

if (distance < 10) {  // This is where the LED On/Off happens
Serial.println("hurdle 1 ");
digitalWrite(led1, LOW);///on

}
else {
digitalWrite(led1, HIGH);

}
}

void get_sonar2() {
digitalWrite(trigPin2, LOW);  // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin2, HIGH);
//  delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin2, HIGH);
distance2 = (duration2/2) / 29.1;

Serial.print("s2=");
Serial.print(distance2);
Serial.print("cm      ");

if (distance2 < 10) {  // This is where the LED On/Off happens
Serial.println("hurdle 2 ");
digitalWrite(led2, LOW);

}else{
digitalWrite(led2, HIGH);

}
}

void get_sonar3(){
digitalWrite(trigPin3, LOW);  // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin3, HIGH);
//  delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin3, LOW);
duration3 = pulseIn(echoPin3, HIGH);
distance3 = (duration3/2) / 29.1;

Serial.print("s3=");
Serial.print(distance3);
Serial.println("cm");
if (distance3 < 10) {  // This is where the LED On/Off happens
Serial.println("hurdle 3 ");
digitalWrite(led3, LOW);

}else {
digitalWrite(led3, HIGH);

}

}

 

 

    Current date/time is Sun Dec 11, 2016 10:56 am