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

Devantech SRF08 sonar

Devantech SRF08 sonar.
The sonar uses the I2C bus and also requires a +5v regulated supply. The sonar can measure distances from about 17cm to about 600 cm. The default I2C address is 0xE0 but can be changed to one of 16 values if you know what you are doing!
This device also has a Light Dependent Resistor (LDR) that measures the ambient light level. This value has no associated 'unit of measurement' but can be used to distinguish 'lighter' versus 'darker'.
Assuming you have called your sensor 'myDistance' in Project Designer then it can be accessed as follows:-
DISTANCE_TYPE cm = myDistance.getDistance();
uint8_t light = myDistance.getLightLevel();
cout << "Distance=" << cm << " Light=" << light;
Or dumped to the standard out destination using:-
cout << myDistance;
Function Summary

Valid XHTML 1.0 Transitional