WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

Maxbotix MB7077 sonar

Maxbotix MB7077 sensor (suitable for use under water).
This sensor can be used in air or in water - although you may need to add extra gloop to make it water proof.
The sonar can output data in a variety of formats - but this library uses the analogue output from the 'AN' pin to an ADC pin on your micro controller.
The device can be powered using either 3.3v or 5v BUT your choice will depend on the reference voltage used by the ADC on your board. ie using 3.3v to power the device from a board that uses 5v as its ADC reference voltage will give wrong readings. But worse: powering the device with 5v from a board that expects a maximum ADC input of 3.3v may fry the ADC unit on your board.
The device can measure up to about 700cm with a 5v supply and up to about 600cm with a 3.3v supply.
The returned range from the device is based on the speed of sound and hence will vary depending upon the medium where it lives. For example: sound travels 4.3 times faster under water than it does through air. For this reason: you can specify whether the device is normally under water in Project Designer.
If your robot is amphibious then you can change the 'inWater' member variable at runtime to reflect the current environment for the device using setInWater.
Assuming you have called your sensor 'myDistance' in Project Designer then it can be accessed as follows:-
DISTANCE_TYPE cm = myDistance.getDistance();
cout << "Distance=" << cm;
Or dumped to the standard out destination using:-
cout << myDistance;
Function Summary

Valid XHTML 1.0 Transitional