Crate gp2d12[][src]

Expand description

An embedded-hal driver for the GP2D12 infrared distance sensor.

Distance calibration is based on the values in the datasheet.

Examples

use gp2d12::Gp2d12;

// 3300 mV max voltage on the ADC, 12-bit precision
let mut gp2d12 = Gp2d12::new(pin, 3300, 12);

// measuring 40 cm
assert_eq!(gp2d12.distance(&mut adc), Ok(Some(40)));

See the STM32F3Discovery example for a complete example.

Structs

Driver for the GP2D12 infrared distance sensor.