/
Embedded Programming and Robotics Embedded Programming and Robotics

Embedded Programming and Robotics - PowerPoint Presentation

briana-ranney
briana-ranney . @briana-ranney
Follow
397 views
Uploaded On 2016-04-18

Embedded Programming and Robotics - PPT Presentation

Lesson 10 Ultrasonic Range Finder Range Finder 1 The Range Finder This analog sensor operates at short distances giving you distance from an object It sends out a pulse of highfrequency sound then measures the time it takes to come back much as bats ID: 283647

finder range high distance range finder distance high pulsein pin pulse trigpin digitalwrite closer duration program time returns sound

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Embedded Programming and Robotics" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Embedded Programming and Robotics

Lesson 10Ultrasonic Range Finder

Range Finder

1Slide2

The Range Finder

This analog sensor operates at short distances, giving you distance from an object

It sends out a pulse of high-frequency sound, then measures the time it takes to come back, much as bats doThe minimum range is about 2 CM, and

the maximum is about 2 meters

Range Finder

2Slide3

The Range Finder

Pins: V

cc and groundTrig causes the rangefinder to send out a soundReading Echo gives you the time it took for the sound to return, and thus distance

Range Finder

3Slide4

The Range Finder

Define the two pins used by the device:

const int TRIGPIN = 7;

const int ECHOPIN = 8;

Range Finder

4Slide5

The Range Finder

Getting the distance:long duration, distance

;digitalWrite(TRIGPIN, LOW

);

delayMicroseconds

(2);

digitalWrite

(TRIGPIN,

HIGH);

delayMicroseconds

(10);

digitalWrite

(TRIGPIN,

LOW);

duration

=

pulseIn

(ECHOPIN,

HIGH);distance = (duration/2) / 29.1;

Range Finder

5Slide6

The

pulseIn Function

pulseIn

(pin, value)

pulseIn

(pin, value, timeout)

Reads

a pulse (either HIGH or LOW) on a

pin

For

example, if

value

is

HIGH

,

pulseIn

()

waits for the pin to go

HIGH

, starts timing, then waits for the pin to go

LOW

and stops timing.

Returns the length of the pulse in microseconds.Gives up and returns 0 if no pulse starts within a specified timeout.

Range Finder

6Slide7

“Follow-Me” Program

Write a program that will follow you at a distance of about a meter

If the robot gets closer than that, it should slow downIf it gets further than that, it should speed upIt should get no closer than 20

CM. Stop if it is closer and wait.

You can make it slowly turn until it finds something to follow

This program is not directional, since the sensor can only tell distance

Range Finder

7