3 releases (breaking)

0.3.0 Nov 21, 2021
0.2.0 Nov 20, 2021
0.1.0 Nov 18, 2021

#1099 in Embedded development

MIT license

8KB
69 lines

gp2d12   Build Status Latest Version Docs Badge

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.

Dependencies

~84KB