Hello, Did anyone succeed in interfacing SRF08 I2C sonar to a PIC? Unfortunately, I couldn't find a datasheet which would describe the I2C communication format. Here's the code I wrote (in CCS C), but it doesn't work (returns 0xFF all the time): while (1) { delay_ms(1000); i2c_start(); i2c_write(0xE0); // address of the ranger i2c_write(0x00); // initiate the distance measurement i2c_write(0x51); // measurement in cm delay_ms(100); // 65ms min i2c_stop(); // read the first echo i2c_start(); i2c_write(0xE0); // address of the ranger i2c_write(0x02); // address of the hight byte of the first echo i2c_start(); iDist = i2c_write(0xE1); // send a write command iDist = i2c_read(); // high byte printf("%02X ", iDist); iDist = i2c_read(); // low byte printf("%02X \n\r", iDist); i2c_stop(); } What am I doing wrong? Nick |
SRF08 - I2C sonar
Started by ●April 13, 2004