ready to alpha
подготовка к альфа-тестированию
This commit is contained in:
commit
e36b851783
164 files changed
+27352
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// i2c_scanner
|
||||
#include <Wire.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
Serial.println("I2C scanner start");
|
||||
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int devicesQty = 0;
|
||||
Serial.println("Scanning...");
|
||||
|
||||
for (byte address = 1; address < 127; address++)
|
||||
{
|
||||
// transmitting address to I2C bus
|
||||
Wire.beginTransmission(address);
|
||||
byte error = Wire.endTransmission();
|
||||
|
||||
// Wire.endTransmission() will return 0 only if an ACK is received
|
||||
// from the subscriber with the current address
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
Serial.print("Device found at address 0x");
|
||||
if (address < 16)
|
||||
Serial.print("0");
|
||||
Serial.println(address, HEX);
|
||||
devicesQty++;
|
||||
}
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
|
||||
if (devicesQty == 0)
|
||||
Serial.println("No device found");
|
||||
else
|
||||
{
|
||||
Serial.print(devicesQty);
|
||||
Serial.println(" devices found");
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
delay(5000);
|
||||
}
|
||||
Reference in new issue
Block a user