Skip to Content
Learn Robotics Programming
book

Learn Robotics Programming

by Danny Staple
November 2018
Beginner
472 pages
13h 5m
English
Packt Publishing
Content preview from Learn Robotics Programming

Reading an ultrasonic distance sensor

To be able to write code for the distance sensor, we will need to look at a few areas of its operation. As suggested previously, this system works by bouncing sound pulses off of objects, and timing their travel time.

A pulse is used on the trigger pin to ask for a sound pulse and timing to be sent. 10 microseconds is this pulse length, that is, 0.00001 seconds:

The echo pin responds by returning a pulse with a length corresponding to the sound travel time. The following diagram shows the timing of these:

Timing of a pulse and the response for an HC-SR04 distance sensor

By measuring the time between the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming - Second Edition

Learn Robotics Programming - Second Edition

Danny Staple

Publisher Resources

ISBN: 9781789340747Supplemental Content