Devantech SRF08 sonar.
The sonar uses the I2C bus and also requires a +5v regulated supply. On the Axon this means using the power headers from an ADC pin. 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.
It may be defined using:
Devantech_SRF08 sensor = MAKE_Devantech_SRF08();
The sensor should be initialised in appInitHardware using:-
The sensor can then be read using:-
and then the distance in cm will be in sensor.distance.cm.
This device also has a Light Dependent Resistor (LDR) that measures the ambient light level. Following a distanceRead command then this value can be read as follows:
uint8_t lightLevel = sensor.ldr;
This value has no associated 'unit of measurement' but can be used to distinguish 'lighter' versus 'darker'.