gp2d12

Crates.iogp2d12
lib.rsgp2d12
version0.3.0
sourcesrc
created_at2021-11-18 21:06:48.775149
updated_at2021-11-21 14:44:42.193241
descriptionDriver for the GP2D12 infrared distance sensor
homepage
repositoryhttps://github.com/peterstuart/gp2d12/
max_upload_size
id484168
size9,330
Peter Stuart (peterstuart)

documentation

README

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.

Commit count: 12

cargo fmt