for (int i = 0; i < 120; i++)
{
Wire.beginTransmission(i);
error = Wire.endTransmission();
sprintf(buf, "scan %i - %i",i,error);
lcd.setCursor(0,1);
lcd.print(buf);
if (error == 0)
{
//success!
delay(1000);
}
}
Instead of lcd.print, you can use any other kind of output. As soon as a device is found, the Arduino waits a second and then continues scanning.
No comments:
Post a Comment