4 const int READ_DURATION = 70;
5 const int RESULT_REGISTER = 0x02;
6 const int DEVICE_ADDRESS = 0x70;
17 this->
_mode = SRF02_CENTIMETERS;
29 void SRF02::sendCommand (
int deviceId,
int command) {
31 Wire.beginTransmission(deviceId);
33 Wire.write((byte)0x00);
34 Wire.write((byte)command);
36 Wire.endTransmission();
39 void SRF02::setRegister(
int deviceId,
int thisRegister) {
41 Wire.beginTransmission(deviceId);
43 Wire.write(thisRegister);
45 Wire.endTransmission();
52 int SRF02::readData(
int deviceId,
int numBytes) {
55 Wire.requestFrom(deviceId, numBytes);
57 while (Wire.available() < 2 ) {
61 result = Wire.read() * 256;
62 result = result + Wire.read();