Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- fblanc
- Date:
- 2014-07-22
- Revision:
- 1:e148be668cc9
- Parent:
- 0:53700355bf8f
File content as of revision 1:e148be668cc9:
#include "mbed.h"
#include "PCF8591.h"
#define VERSION "22_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)
}
}