#include void setup() { Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output } void loop() { int dataLength = 6; int timesFound = 0; Serial.println("Ready or not, here I come..."); for(byte attempt = 0; attempt <= 25; attempt++) { int address = pickARandomAddress(); Serial.print("I am looking for you in address "); Serial.print(address); Wire.requestFrom(address, dataLength); delay(10); if (Wire.available()) { timesFound++; Serial.println(" - I found youuu! :)"); flushReadBuffer(); }else{ Serial.println(" - nope :("); } } Serial.print("I found you "); Serial.print(timesFound); Serial.println(" times\n"); delay(2000); } void flushReadBuffer(){ while (Wire.available()) { char c = Wire.read(); } } int pickARandomAddress() { int busMinAddress = 1; int busMaxAddress = 50; return random(busMinAddress, busMaxAddress); }