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