Open OzGrant opened 10 years ago
Wire.endTransmission() always returns a zero even when I2C scanner looking for addresses. Fixed by adding a Wire.write(1) before the command. Grant.
------------------------------------------------ // I2C scanner for M430G2553 // Added Wire.write(1); for sketch to work. // Grant Forest May 2014 #include "Wire.h" uint8_t error, address; void setup () { Serial.begin(9600); Serial.println("G'Day MyI2C_ScannerV1"); Wire.begin(); } void loop () { Serial.print(" Scanning..."); for(address = 1; address < 127; address++ ) { Wire.beginTransmission(address); Wire.write(1); ///////////////////////////////////// sketch works ok when this line added error = Wire.endTransmission(); if (error==0) { Serial.print("Found Address 0x"); if (address<15) Serial.print('0'); Serial.print(address,HEX); Serial.print(", "); } } Serial.println(); delay(2000); }
See discussion at http://forum.43oh.com/topic/5473-i2c-scanner-for-2553-5529/
Wire.endTransmission() always returns a zero even when I2C scanner looking for addresses. Fixed by adding a Wire.write(1) before the command. Grant.