Hubei Hannas Tech Co.,Ltd-Professional Piezoceramic Elements Supplier
News
You are here: Home / News / Ultrasonic Transducer information / How to connect ultrasonic sensor to Arduino Uno

How to connect ultrasonic sensor to Arduino Uno

Views: 4     Author: Site Editor     Publish Time: 2020-06-05      Origin: Site

Inquire

facebook sharing button
twitter sharing button
line sharing button
wechat sharing button
linkedin sharing button
pinterest sharing button
whatsapp sharing button
sharethis sharing button

Step 1: Hardware connection


DF`3EOY7DSNANUS26)OOC


)7FCNSA0H)(8`Q_8FR8GJ



EAQJOS`LH%YD0JKAYD9


XG7%S6F`8PJ4TIH412%XU


Hardware connection: -Arduino piezoelectric ultrasonic transducer Ultrasonic Sensor 5v-Vccgnd-Gnd

Pin No. 8-Trig Pin

Pin 7-"Echo Pin

Arduino buzzer

9th stitch -> +ve stitch

Gnd--ve needle

Step 2: Procedures and results

M73LNFPYXQYZ3)R`4DVGL


Ultrasonic sensor and Arduino interface.

int buzzer = 9;

int triggerPin = 7;//Trigger pin 7

int echoPin = 8;//Echo pin 8

void setup()

Serial.begin (9600); We will start serial communication, so we can see the distance on the serial monitor Serial.println ("Tech Ponder‘s ultrasonic distance measurement sensor Tutorial").

pinMode (triggerPin, OUTPUT); //define the pin

pinMode (echoPin, INPUT);

pinMode (buzzer, output);

digitalWrite (buzzer, LOW);}

void loop()

{int duration, distance;//Add duration and distance

digitalWrite (triggerPin, HIGH);//trigger wave (for example to make the LED blink)

delay(10);

digitalWrite (triggerPin, LOW);

duration = pulseIn (echoPin, HIGH);//Special functions for listening and waiting for waves

distance = (duration/2)/29.1;//Convert the number to cm (If you want inches, you must change 29.1 with the appropriate number

delay (1000);

Serial.print (distance); print numbers

Serial.print ("cm"); and unit

Serial.println (""); only print to a new line

if (distance "35"

digitalWrite (buzzer, HIGH);

Serial.println ("Buzzer On");

digitalWrite (buzzer, LOW);

The result is displayed on the serial monitor.

Arduino uses an ultrasonic distance sensor to calculate the distance every second. When the distance is less than 35 cm, arduino will detect the threshold and the buzzer will turn on, which can be used as an obstacle detector. When the obstacle is closer than 35 cm, it will sound an alarm.


Feedback
Hubei Hannas Tech Co.,Ltd  is a professional piezoelectric ceramics and ultrasonic transducer manufacturer, dedicated to ultrasonic technology and industrial applications.                                    
 

RECOMMEND

CONTACT US

Add: No.302 Innovation Agglomeration Zone, Chibi Avenu ,Chibi City, Xianning, Hubei Province,China
E-mail: sales@piezohannas.com
Tel: +86 07155272177
Phone: +86 +18986196674         
QQ: 1553242848 
Skype: live:mary_14398
​        
Copyright 2017  Hubei Hannas Tech Co.,Ltd All rights reserved. 
Products