It is simple to use PCF8591 Library (ADC / DAC converter) for LPC800MAX
Fork of PCF8591 by
PCF8591.h
00001 #include "mbed.h" 00002 #include "stdio.h" 00003 00004 00005 //init_adc(pin sda, pin scl, address, ADC mux, DAC value) return 1/0 (1-transmission ok) 00006 00007 // adc(pin sda, pin scl, address, ADC mux) return ADC value 00008 00009 int init_adc (PinName sda, PinName scl,unsigned char addr, char mux,char dac_) 00010 { 00011 const char comm[] = {0x40+mux,dac_}; 00012 I2C p_i2c(sda,scl); 00013 return(p_i2c.write(addr,comm,2)); 00014 } 00015 00016 int adc (PinName sda, PinName scl,char addr) 00017 { 00018 char response[1]; 00019 I2C p_i2c(sda,scl); 00020 p_i2c.read((addr+0x01), response, 1); 00021 return(response[0]); 00022 }
Generated on Fri Jul 15 2022 19:29:10 by 1.7.2