1. #include <Wire.h>
  2.  
  3. void setup() {
  4. Serial.begin (115200);
  5.  
  6. // Leonardo: wait for serial port to connect
  7. while (!Serial)
  8. {
  9. }
  10.  
  11. Serial.println ();
  12. Serial.println ("I2C scanner. Scanning ...");
  13. byte count = 0;
  14.  
  15. Wire.begin();
  16. for (byte i = 8; i < 120; i++)
  17. {
  18. Wire.beginTransmission (i);
  19. if (Wire.endTransmission () == 0)
  20. {
  21. Serial.print ("Found address: ");
  22. Serial.print (i, DEC);
  23. Serial.print (" (0x");
  24. Serial.print (i, HEX);
  25. Serial.println (")");
  26. count++;
  27. delay (1); // maybe unneeded?
  28. } // end of good response
  29. } // end of for loop
  30. Serial.println ("Done.");
  31. Serial.print ("Found ");
  32. Serial.print (count, DEC);
  33. Serial.println (" device(s).");
  34. } // end of setup
  35.  
  36. void loop() {}