1234567891011121314151617181920212223242526272829 |
- #include <Wire.h>
- void setup() {
- Serial.begin(115200);
- Wire.begin(23, 19); // SDA, SCL
- Serial.println("\nI2C Scanner");
- }
- void loop() {
- byte error, address;
- int nDevices = 0;
- for (address = 1; address < 127; address++) {
- Wire.beginTransmission(address);
- error = Wire.endTransmission();
- if (error == 0) {
- Serial.printf("I2C device found at 0x%02X\n", address);
- nDevices++;
- }
- }
- if (nDevices == 0)
- Serial.println("No I2C devices found");
- else
- Serial.println("Scan done.");
- delay(2000);
- }
|