#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.begin();
Serial.begin(9600);
Serial.println("\nI2C Scanner");
}
void loop() {
byte error , address ;
int Devices;
Serial.println("Scanning");
Devices = 0;
for (address = 1; address<127;address++){
Wire.beginTransmission(address);
error = Wire.endTransmission();
if(error == 0){
Serial.print("I2C device found at adrress x0");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.print(" !");
Devices++;
}
else if(error==4)
{
Serial.print(("Unkown error at Address 0x"));
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (Devices == 0)
Serial.println("No I2C Devices found \n");
else
Serial.println("done\n");
delay(5000);
// put your main code here, to run repeatedly:
}