Skip to main content

ultrasonic sensor interface with arduino

Project Name:- Ultrasound sensor interface with arduino 


Today i m going to interface the  ultrasonic sensor with arduino arduino.

# Components required
   1> Ultrasonic sensor
   2> Arduino
   3>Arduino cable
   4>Computer with arduino ide software




Ultrasonic sensor


                                                         fig:- ultrasonic sensor
Ultrasonic sensor is a special type of transducer used for ultrasonic proximity sensors, It allows the transmission and reception of the sound waves.The sound wave is emitted by the transducer which are strike on object and returns to the receiver of transducer. Time delay between transmitting and receiving the sound waves is directly proportional to the distance of the object which is clearly shown on figure below

                                          Fig:- Working mechanism of ultrasonic sensor

circuit connection

Ultrasonic sensor has four pin  VCC,GND,Trigger and Echo. VCC and GND are connected to 5V and Gnd pin on arduino respectively. Trigger and Echo pins are connected to 12 and 11 number pins of  arduino.


                                                                Fig:-circuit diagram

When the circuit is completed then connect the arduino with PC using arduino cable and upload the following code.



Code
#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

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

void loop() {
  delay(50);  // Wait 50MS between pings (about 20 pings/sec). 29MS should be the shortest delay between pings.
  Serial.print("Ping: ");
  int value=sonar.ping_cm();
  Serial.print(value);// Send ping, get distance in cm and print result (0 = outside set distance range)
  Serial.println("cm");
  }

Upload the code



Open the serial monitor

  

Serial monitor display the measured distance by ultrasound sensor


Popular posts from this blog

warm clothes distribution program

‘ Small step can make a big difference ’ Rural Women Development Centre from morang,Nepal distributed the warm clothes to the needy people. They manage it possible by collecting fund from working staffs and management committe. Here is the video link of the distribution program. https://youtu.be/AxaHbivcQUM

SMPS of computer

                                            fig:- working principle of SMPS       fig :- SMPS of computer From the above figure, we came to know that the function of SMPS in computer which is to convert  the high 220V-AC to 0-12V DC.SMPS contain several color of wires which carry the different voltage to the different parts of the computer.The following table shows the different color cables and its carrying voltage.      

Multiple mcp23017 interfacing with Arduino

MCP23017 is the I/O port extender that runs on 12C. It is 16-bit I/O expender.in this tutorial we are going to interface the single and multiple  mcp23017 with arduino.  fig:- mcp32017 module IT has 16 I/O ports from PA0 to PA7 and PB0 to PB7. first of all we are going to interface the single mcp23017 with Arduino. For this  connect the circuit as shown on figure. Download the library for mcp23017  from  sketch-- include library -- manage libraries.