Étape 4: Le Code
/ / Écrit par Nick Gammon
Date : 20 avril 2011
#include < Wire.h >
void setup() {}
Serial.Begin (115 200 bauds) ;
Leonardo : attendre pour port série connecter
while (!. Serial)
{
}
Serial.println () ;
Serial.println "(I2C scanner. Numérisation...") ;
nombre d’octets = 0 ;
Wire.Begin() ;
pour (octet j’ai = 1; i < 120; i ++)
{
Wire.beginTransmission (i) ;
Si (Wire.endTransmission () == 0)
{
Serial.Print ("adresse:") ;
Serial.Print (i, DEC) ;
Serial.Print ("(0 x") ;
Serial.Print (i, HEX) ;
Serial.println (")") ;
Count ++ ;
retard (1) ; peut-être inutiles ?
} / / fin de bonne réponse
} / / fin de boucle for
Serial.println ("terminé.") ;
Serial.Print ("Found") ;
Serial.Print (comptage, DEC) ;
Serial.println ("device(s).") ;
} / / fin de l’installation
void loop() {}