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);
}
}
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);
}
}
Sat Apr 29, 2017 10:50 am by ubedullah
» Group hackers
Sat Apr 15, 2017 2:37 pm by Group Hackers
» Hacker Needed
Sat Apr 15, 2017 3:57 am by Group Hackers
» Hacker Needed
Sat Apr 15, 2017 1:45 am by Group Hackers
» Hacker Needed
Thu Apr 13, 2017 11:10 pm by Group Hackers
» Hacker Needed
Tue Apr 11, 2017 2:07 pm by Group Hackers
» Hacker Needed
Tue Apr 11, 2017 2:21 am by Group Hackers
» Hacker Needed
Tue Apr 11, 2017 2:06 am by Group Hackers
» Hacker Needed
Tue Apr 11, 2017 1:35 am by Group Hackers