SeeedStudio Grove-I2C ADC Manual page 10

Table of Contents

Advertisement

#define REG_ADDR_CONVH
unsigned int
getData;
float
analogVal=0;
void
init_adc()
{
Wire.beginTransmission(ADDR_ADC121);
Wire.write(REG_ADDR_CONFIG);
Wire.write(0x20);
Wire.endTransmission();
}
void
read_adc()
{
Wire.beginTransmission(ADDR_ADC121);
Wire.write(REG_ADDR_RESULT);
Wire.endTransmission();
Wire.requestFrom(ADDR_ADC121, 2);
device
delay(1);
if(Wire.available()<=2)
{
getData
= (Wire.read()&0x0f)<<8;
getData
|= Wire.read();
}
Serial.print("getData:");
Serial.println(getData);
delay(5);
Serial.print("The analog value
Serial.print(getData*V_REF*2/4096);
Serial.println("V");
}
void
setup()
{
Serial.begin(9600);
Wire.begin();
init_adc();
}
void
loop()
{
read_adc();//adcRead);
0x07
// convert
//unsigned int *data
is:");
7
// transmit to device
// Configuration Register
// transmit to device
// get result
// request 2byte from

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Grove-I2C ADC and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents