Other Parts Discussed in Thread: LDC1312, LDC1314
Hi guys!
Sorry in advance if my question/issue is very elementary!
I am trying to communicate with the LCD1312 chip using I2C as claimed in the description. I'm using an Arduino to do so. I made the connection and after checking the data sheet carefully, I cannot read out the inductance. All I'm getting is 255. I tried to look up online if someone has done similarly, but it was not successful. Attached is my code in Arduino:
P.S. I have no experience in i2c previously, unfortunately. I do receive packages of bytes, but both are 255.
Also, I connected pull up resistors in series each with SDA and SCL.
////////////////////////////
#include <Wire.h>
void setup() {
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}
int reading1 , reading2 ;
byte d;
void loop() {
// step 1: instruct sensor to read echoes
Wire.beginTransmission(42); // 0x2A if ADDR is high
Wire.write(byte(0x00)); // Choosing whether to Read or Write
Wire.write(byte(0x00)); // Address to read (channel one is at address 0 according to the datasheet)
Wire.endTransmission(); // stop transmitting
delay(70); //
Wire.beginTransmission(42); //
Wire.write(byte(0x01)); // Read
Wire.endTransmission(); // stop transmitting
//
Wire.requestFrom(42, 2); //
//
int wireAv = Wire.available();
int index = 0;
Serial.println(wireAv);
if (wireAv)
{
d = Wire.read();
Serial.println("in while ");
Serial.print("d is ");
Serial.println(d,DEC);
Serial.println(" ");
}
// if (2 <= wireAv ) { // if two bytes were received
// reading1 = Wire.read(); // receive high byte (overwrites previous reading)
// /*reading1 = reading1 << 8; // shift high byte to be high 8 bits
// reading1 |= Wire.read(); // receive low byte as lower 8 bits
// */
// Serial.println(reading1); // print the reading
// }
delay(250); // wait a bit since people have to read the output :slightly_smiling_face:
}
//////////////////////
Thanks!
Cheers,