Multiple ultrasonic Sensors with Arduino

 How to connect Multiple Ultrasonic Sensors with Arduino



Items Required

1) Arduino Nano

2) Ultrasonic Sensors x 4

3) buzzer

4) Bread board


Library:- https://drive.google.com/file/d/1kc1FOsRMJr7w2pBU_zlwcFT9D6wumdcs/view?usp=sharing


Code

---------------------------------------------------------------------------------------


#include <NewPing.h>

#define SONAR_NUM 3      // Number of sensors.
#define MAX_DISTANCE 200 // Maximum distance (in cm) to ping.

NewPing sonar[SONAR_NUM] = {   // Sensor object array.
  NewPing(4, 5, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
  NewPing(6, 7, MAX_DISTANCE),
  NewPing(8, 9, MAX_DISTANCE)
};

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through each sensor and display results.
    delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
    Serial.print(i);
    Serial.print("=");
    Serial.print(sonar[i].ping_cm());
    Serial.print("cm ");
  }
  Serial.println();
}

--------------------------------------------------------------------------------------

Circuit Diagram



Multiple Ultrasonic Sensor based  Security alaram



Circuit Diagram


Code:



Ultrasonic Sensor based Automatic Fan

Hello Friends, Today in this video i am going to show you how to make an automatic Fan using ultra sonic sensor, we can set the range when any object comes within the range the fan will start working, when some one moves out of its range then the fan will gets off automatically, i hope you will enjoy the circuit and video, i explained the code in easiest language,




Circuit diagram



Code:




No comments:

Post a Comment

Wifi Home automation Diy kit

 Wifi Home automation Diy kit By Manmohan Pal Wifi Home Automation Kit Hi, This is Manmohan Pal, I am glad to present a DIY kit for Home Aut...