| 1234567891011121314151617181920212223 |
- #include "MCP3428.h"
- float MCP3428_Read(uint8_t channel) {
-
- Wire.beginTransmission(MCP3428_ADDRESS);
- Wire.write(getChannelConfigByte(channel));
- Wire.endTransmission();
-
- delay(200);
- byte config,byte1,byte2;
- while(1){
- Wire.requestFrom(MCP3428_ADDRESS, 3);
- byte2 = Wire.read();
- byte1 = Wire.read();
- config = Wire.read();
- if(config>>8==0) //tant qu'il a pas fini
- break;
- }
- int value = ((byte2) << 8) | byte1;
- Serial.print(value);
- return ((float)value * 62.5)/1000000;
- }
|