Files
Adafruit_nRF52_Arduino/libraries/Wire/examples/master_scan/master_scan.ino
T
2019-10-21 10:35:12 +07:00

29 lines
572 B
Arduino

#include <Wire.h>
TwoWire *wi = &Wire;
//TwoWire *wi = &Wire1;
void setup()
{
Serial.begin(115200); // start serial for output
while ( !Serial ) delay(10); // for nrf52840 with native usb
wi->begin(); // join i2c bus (address optional for master)
}
void loop()
{
Serial.println("Scanning address from 0 to 127");
for (int addr = 1; addr < 128; addr++)
{
wi->beginTransmission(addr);
if ( 0 == wi->endTransmission() )
{
Serial.print("Found: 0x");
Serial.print(addr, HEX);
Serial.println();
}
}
delay(5000);
}