Crates.io | gp2d12 |
lib.rs | gp2d12 |
version | 0.3.0 |
source | src |
created_at | 2021-11-18 21:06:48.775149 |
updated_at | 2021-11-21 14:44:42.193241 |
description | Driver for the GP2D12 infrared distance sensor |
homepage | |
repository | https://github.com/peterstuart/gp2d12/ |
max_upload_size | |
id | 484168 |
size | 9,330 |
An embedded-hal driver for the GP2D12 infrared distance sensor.
Distance calibration is based on the values in the datasheet.
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.