Hello?
I am trying to rewrite a code, which is written in CCS-C
i2c_start();
i2c_write(0x9B); //MCP3221 address is 0x9B
ad_high = i2c_read(1); //indicate to ack
ad_low = i2c_read(0);
i2c_stop();
ADC_result = (ad_high * 256) + ad_low;
This code works fine with CCS-C, and I modified it as follow, but it does not work
Probably, I need to send ack after reading the first byte, but
do not know how to send ack with Wire.receive
ad_high = Wire.receive(1); // if I put "1", this makes compile error
Could someone help me?
====================================================
#include <Wire.h>
#define ADDRESS 0x9B //defines address of MCP3221 12bit ADC
void setup(){
Wire.begin(); //conects I2C
Serial.begin(9600);
}
void loop(){
byte ad_high;
byte ad_low;
int Result;
Serial.println("Let's begin");
Wire.beginTransmission(ADDRESS);
ad_high = Wire.receive();
ad_low = Wire.receive();
Wire.endTransmission();
Result = (ad_high * 256) + ad_low;
Serial.println(Result);
delay(100);
}
Thanks
Eaton