www.i4info.org

Would you like to react to this message? Create an account in a few clicks or log in to continue.
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

» Teen Patti Gold Hack & 3 Patti Chips Code Extra Bonus 2017
multiple sonar sensors using  arduino EmptySat Apr 29, 2017 10:50 am by ubedullah

» Group hackers
multiple sonar sensors using  arduino EmptySat Apr 15, 2017 2:37 pm by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptySat Apr 15, 2017 3:57 am by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptySat Apr 15, 2017 1:45 am by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptyThu Apr 13, 2017 11:10 pm by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptyTue Apr 11, 2017 2:07 pm by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptyTue Apr 11, 2017 2:21 am by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptyTue Apr 11, 2017 2:06 am by Group Hackers

» Hacker Needed
multiple sonar sensors using  arduino EmptyTue Apr 11, 2017 1:35 am by Group Hackers

May 2024

MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  

Calendar Calendar

Affiliates


free forum

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

Visitors Counter


Flag Counter


    multiple sonar sensors using arduino

    Admin
    Admin
    Admin


    Posts : 474
    Reputation : 8
    Join date : 2014-12-10
    Age : 31
    Location : Pakistan

    multiple sonar sensors using  arduino Empty multiple sonar sensors using arduino

    Post by Admin 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 May 12, 2024 12:34 am