This commit is contained in:
caternuson 2023-12-05 12:07:58 -08:00
parent 8ea00f2bca
commit dba53b305f

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2023 Carter Nelson for Adafruit Industries
//
// SPDX-License-Identifier: MIT
// --------------------------------------
// i2c_scanner
//
@ -26,7 +29,7 @@ void loop() {
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
@ -37,20 +40,20 @@ void loop() {
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");