Init fork from Stuart Robinson's repo

This commit is contained in:
2024-10-03 14:30:13 +03:00
commit 9395706524
201 changed files with 45709 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
// --------------------------------------
// i2c_scanner
// from: https://playground.arduino.cc/Main/I2cScanner/
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
#include <Wire.h>
uint16_t counter;
#define SDA 21
#define SCL 22
void setup()
{
Wire.begin(SDA, SCL); //format is Wire.begin(SDA,SCL);
Serial.begin(9600);
Serial.println(F("I2C Scanner starting"));
Serial.println();
}
void loop()
{
uint8_t error, address;
int16_t nDevices;
counter++;
Serial.print(counter);
Serial.println(F(" Scanning..."));
nDevices = 0;
for (address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print(F("I2C device found at address 0x"));
if (address < 16)
Serial.print(F("0"));
Serial.println(address, HEX);
nDevices++;
}
else if (error == 4)
{
Serial.print(F("Unknown error at address 0x"));
if (address < 16)
Serial.print(F("0"));
Serial.println(address, HEX);
}
}
if (nDevices == 0)
{
Serial.println(F("No I2C devices found"));
}
else
{
Serial.println();
Serial.println(F("Done"));
Serial.println();
}
delay(5000); // wait 5 seconds for next scan
}