test PCF

Dependencies:   PCF8591 mbed

Revision:
0:53700355bf8f
Child:
1:e148be668cc9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jul 22 13:32:47 2014 +0000
@@ -0,0 +1,33 @@
+ #include "mbed.h"
+ #include "PCF8591.h"
+ #define VERSION "21_07_2014"
+ #define CIBLE "KL25Z"
+ // I2C Communication
+  I2C i2c_adcdac(PTC9,PTC8); // SDA, SCL for LPC1768
+  //I2C i2c_adcdac(P0_10,P0_11); // SDA, SCL for LPC812
+ 
+  //Declare a composite ADC and DAC device that may be used through public methods
+  PCF8591 capteur0(&i2c_adcdac,PCF8591_SA0); // I2C bus, Default PCF8591 Slaveaddress
+ 
+  //Declare independent ADC and DAC objects that may be used similar to mbed AnalogIn and AnalogOut pins
+  //PCF8591_AnalogOut anaOut(&i2c_bus);
+  //
+  //PCF8591_AnalogIn anaIn(&i2c_bus, PCF8591_ADC0);
+ 
+  
+  int main() {
+    uint8_t count = 0; 
+    uint8_t analog;  
+    printf("LAAS-CNRS ,PCF8591 ,%s ,%s\r\n",CIBLE,VERSION);
+    while(1) {
+      wait(1);    
+      count++;       
+ 
+      // Composite device methods    
+     capteur0.write(count);                 // write D/A value
+     analog = capteur0.read(PCF8591_ADC0);  // read A/D value for Channel 0
+printf("AO=%d AI=%d \r\n",count,analog);
+              // read A/D value for Channel 0 in (Volts*10)
+  }
+ 
+ }
\ No newline at end of file