i am trying to configure ARDUINO DUE and SRF10 ultrasonic sensor. i have my code ready but while running the code i am getting the error below.
assertion "(address & 0x80) == 0" failed: file "../source/twi.c", line 261, function: TWI_StartWrite
Exiting with status 1
#include <Wire.h>
void setup()
{
Serial.begin(9600);
Serial.println("SFR10 test application");
Wire.begin(); // join i2c bus (address optional for master)
Serial.println("i2c initialized");
}
#define SFR10_ADDRESS 0xE0
int getDistance(void) {
// 1. start measurement
// write to command register (0x00) of SRF10
Wire.beginTransmission(SFR10_ADDRESS); // transmit to device #112 (0x70)
// the address specified in the datasheet is 224 (0xE0)
// but i2c adressing uses the high 7 bits so it's 112
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
Wire.write(byte(0x51)); // command sensor to measure in "inches" (0x50)
// use 0x51 for centimeters
// use 0x52 for ping microseconds
Wire.endTransmission(); // stop transmitting
// 2. wait until measurement is finished
delay(70); // datasheet suggests at least 65 milliseconds
// 3. read the value
Wire.beginTransmission(SFR10_ADDRESS); // transmit to device #112
Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(); // stop transmitting
Wire.requestFrom(SFR10_ADDRESS, 2); // request 2 bytes from slave device #112
// (4.) make a conversion cm
// already done
// 5. return the value in cm
int reading;
if(2 <= Wire.available()) // if two bytes were received
{
reading = Wire.read(); // receive high byte (overwrites previous reading)
reading = reading << 8; // shift high byte to be high 8 bits
reading |= Wire.read(); // receive low byte as lower 8 bits
}
return reading;
}
void loop()
{
int distance;
distance=getDistance();
Serial.println(distance); // print the reading
delay(200);
}


