Library with PCF8591 support for the experiments for LPC812 MAX

Dependents:   lpc812_exp_solution_analog-in lpc812_exp_solution_7-segment lpc812_exp_solution_7-segment-shift lpc812_exp_solution_pwm ... more

Fork of lpc812_exp_lib_PCF8591 by EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

PCF8591 Class Reference

PCF8591 Class Reference

Interface to the PCF8591 chip (http://www.nxp.com/documents/data_sheet/PCF8591.pdf) which has four 8-bit analog inputs and one 8-bit analog output. More...

#include <PCF8591.h>

Public Member Functions

 PCF8591 (PinName sda=P0_10, PinName scl=P0_11, int i2cAddr=0x9E)
 Create an interface to the PCF8591 chip.
int read (AnalogIn port)
 Reads one value for the specified analog port.

Detailed Description

Interface to the PCF8591 chip (http://www.nxp.com/documents/data_sheet/PCF8591.pdf) which has four 8-bit analog inputs and one 8-bit analog output.

 #include "mbed.h"

 PCF8591 adc;

 int main(void) {

    while(1) {
       // read analog value
       int val = adc.read(PCF8591::A0);

       // do something with value...
    }
 }

Definition at line 24 of file PCF8591.h.


Constructor & Destructor Documentation

PCF8591 ( PinName  sda = P0_10,
PinName  scl = P0_11,
int  i2cAddr = 0x9E 
)

Create an interface to the PCF8591 chip.

Parameters:
sdathe I2C SDA pin
sclthe I2C SCL pin
i2cAddrthe upper 7 bits of the chip's address

Definition at line 4 of file PCF8591.cpp.


Member Function Documentation

int read ( AnalogIn  port )

Reads one value for the specified analog port.

Parameters:
portthe analog in to read (A0..A3)
Returns:
the value on success (0..255) -1 on failure

Definition at line 10 of file PCF8591.cpp.