Maxbotix Ultrasonic Distance Sensor The distance sensor emits

Maxbotix Ultrasonic Distance Sensor The distance sensor emits short bursts of sound and listens for this sound to echo off of nearby objects. The frequency of the sound is too high for humans to hear (it is ultrasonic). The sensor measures the time of flight of the sound burst and determines distance using the time of flight and the speed of sound (1, 126 ft/s). nsor waves leave se re u ss re p ic n ultraso e a speaker) (sensor acts lik t ff objec o s t c e l f wave re sensor c i n o s a ultr rns to u t e r phone) d o r c an i m a cts like a r o s n (se

DISCLAIMER & USAGE The content of this presentation is for informational purposes only and is intended only for students attending Louisiana Tech University. The author of this information does not make any claims as to the validity or accuracy of the information or methods presented. Any procedures demonstrated here are potentially dangerous and could result in injury or damage. Louisiana Tech University and the State of Louisiana, their officers, employees, agents or volunteers, are not liable or responsible for any injuries, illness, damage or losses which may result from your using the materials or ideas, or from your performing the experiments or procedures depicted in this presentation. If you do not agree, then do not view this content. The copyright label, the Louisiana Tech logo, and the “living with the lab” identifier should not be removed from this presentation. You may modify this work for your own purposes as long as attribution is clearly provided. 2

computing distance 3

specifications for MB 1261 • • • reliable measurement range: 50 cm to 10 m (20 inches to 35 feet) supply voltage: 3. 3 V to 5 V (we will use 5 V) frequency: 42 k. Hz (human hearing = 20 Hz to 20 k. Hz) 10 readings can be taken per second (10 Hz sampling) analog voltage output of Vcc/1024 for every 2 cm (for Vcc=5 V and a 10 -bit ADC, an output change of 1 = 2 cm) MB 1261 4

11 -inch wide board beam pattern sensor can see a 0. 25 -inch diameter dowel 6 -feet away if it is straight ahead 3. 5 -inch diameter dowel 1 -inch diameter dowel 0. 25 -inch diameter dowel can’t see me 5

POWER 0 1 2 3 4 5 RESET 3 V 3 5 V GND Vin AREF GND 13 12 PMW 11 PMW 10 PMW 9 8 7 PMW 6 PMW 5 4 PMW 3 2 TX 1 RX 0 connection to an Arduino MB 1261 DIGITAL Arduino ANALOG 6

connection to an Arduino 7

Arduino sketch void setup() { Serial. begin(9600); } void loop() { int output = analog. Read(0); int distance. CM = output * 2; float distance. IN = distance. CM / 2. 54; float distance. FT = distance. IN / 12. 0; Serial. println(distance. CM); delay(1000); // use a baud rate of 9600 bps when printing to the monitor // // read the voltage compute distance at in in in analog pin 0 centimeters inches feet // print out distance in centimeters on LCD // wait 1000 ms between readings } 8

example application A piezospeaker is installed on the breadboard to allow the device to output an irritating noise whose frequency is proportional to the distance from the sensor to a target. void setup() { Serial. begin(9600); pin. Mode(12, OUTPUT); } void loop() { int output = analog. Read(0); int distance. CM = output * 2; float distance. IN = distance. CM / 2. 54; float distance. FT = distance. IN / 12. 0; int tone_freq = distance. CM*40; tone(12, tone_freq); // use a baud rate of 9600 bps when printing to the monitor // declare pin 12 as an output for speaker // // read the voltage compute distance at in in in analog pin 0 centimeters inches feet // a freq of 40*cm is good // send a tone out of pin 12 } digital output (pin 12) 9
- Slides: 9