I2C Scanner
/*H********************************************************************
* I2C Address Scanner
**********************************************************************/
#include <Wire.h>

/*F********************************************************************
*
**********************************************************************/
void 
setup()
{
	Wire.begin();
	Serial.begin(9600);
	Serial.println("\nI2C Scanner");
}
/*F********************************************************************
*
**********************************************************************/
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 address 0x");
			if( address < 16 )
				Serial.print( "0" );
			Serial.print( address, HEX );
			Serial.println( "  !" );
			Devices++;
		}
		else if( error == 4 )
		{
			Serial.print( "Unknown error at address 0x");
			if( address < 16 )
				Serial.print( "0" );
			Serial.println( address, HEX );
		}
	}
	if( Devices == 0)
		Serial.print( "No I2C devices found\n");
	else
		Serial.print( "done\n" );
	delay( 5000 );          
}