display_test_ssd1306.ino 576 B

1234567891011121314151617181920212223242526272829
  1. #include <Wire.h>
  2. void setup() {
  3. Serial.begin(115200);
  4. Wire.begin(23, 19); // SDA, SCL
  5. Serial.println("\nI2C Scanner");
  6. }
  7. void loop() {
  8. byte error, address;
  9. int nDevices = 0;
  10. for (address = 1; address < 127; address++) {
  11. Wire.beginTransmission(address);
  12. error = Wire.endTransmission();
  13. if (error == 0) {
  14. Serial.printf("I2C device found at 0x%02X\n", address);
  15. nDevices++;
  16. }
  17. }
  18. if (nDevices == 0)
  19. Serial.println("No I2C devices found");
  20. else
  21. Serial.println("Scan done.");
  22. delay(2000);
  23. }