Skip to content

Instantly share code, notes, and snippets.

@mutkuensert
Created May 27, 2025 21:07
Show Gist options
  • Select an option

  • Save mutkuensert/9c3fac9ce9e0cfe8f150acb444c50160 to your computer and use it in GitHub Desktop.

Select an option

Save mutkuensert/9c3fac9ce9e0cfe8f150acb444c50160 to your computer and use it in GitHub Desktop.
void scanScreenAddress() {
Wire.begin();
Serial.begin(4800);
while (!Serial)
; // Needed for some cards, No problem for Nano
Serial.println("Scanning I2C devices...");
byte count = 0;
for (byte addr = 1; addr < 127; addr++) {
Wire.beginTransmission(addr);
if (Wire.endTransmission() == 0) {
Serial.print("Device found: 0x");
Serial.println(addr, HEX);
count++;
}
}
if (count == 0) {
Serial.println("No I2C device found.");
} else {
Serial.println("Scan has been finished.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment