#include "MCP3428.h" byte getChannelConfigByte(int channel) { byte configByte = 0x88; // Configuration par défaut pour le canal 1 if (channel == 1) { configByte = 0xA8; } else if (channel == 2) { configByte = 0xC8; } else if (channel == 3) { configByte = 0xE8; } return configByte; } 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; return ((float)value * 62.5)/1000000; }