Crate pcf8591

Source
Expand description

An API to communicate with PCF8591 A/D converter

Official doc

§Examples

use pcf8591::{PCF8591, Pin};
use std::thread;
use std::time::Duration;

// Gets default location on raspberry pi (rev 2)
let mut converter = PCF8591::new("/dev/i2c-1", 0x48, 3.3).unwrap();

loop {
    let v = converter.analog_read(Pin::AIN0).unwrap();
    println!("Input voltage at pin 0: {}", v);

    thread::sleep(Duration::from_millis(1000));
}

Structs§

PCF8591
A struct to handle PCF8591 converter

Enums§

LinuxI2CError
Pin
An input Pin enumeration corresponding to the physical analog inputs pins

Type Aliases§

Result
Wrapper over LinuxI2CError