diff options
| author | abel <71026016+ableTI@users.noreply.github.com> | 2024-04-11 15:24:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-11 15:24:24 +0200 |
| commit | 163f13ca6b75e8c54784b66703a8c316111a9545 (patch) | |
| tree | 5560128b658de802b11f4685cd925796aaaa2b54 | |
| parent | 1f772df82135114ef3bbe4ef259fdd30d5981f7b (diff) | |
| download | robotica-163f13ca6b75e8c54784b66703a8c316111a9545.tar.gz robotica-163f13ca6b75e8c54784b66703a8c316111a9545.zip | |
Add files via upload
| -rw-r--r-- | collorsens/collorsens.ino | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/collorsens/collorsens.ino b/collorsens/collorsens.ino new file mode 100644 index 0000000..e961fd5 --- /dev/null +++ b/collorsens/collorsens.ino @@ -0,0 +1,50 @@ +/** + * TCA9548 I2CScanner.ino -- I2C bus scanner for Arduino + * + * Based on https://playground.arduino.cc/Main/I2cScanner/ + * + */ + +#include "Wire.h" + +#define TCAADDR 0x70 + +void tcaselect(uint8_t i) { + if (i > 7) return; + + Wire.beginTransmission(TCAADDR); + Wire.write(1 << i); + Wire.endTransmission(); +} + + +// standard Arduino setup() +void setup() +{ + while (!Serial); + delay(1000); + + Wire.begin(); + + Serial.begin(115200); + Serial.println("\nTCAScanner ready!"); + + for (uint8_t t=0; t<8; t++) { + tcaselect(t); + Serial.print("TCA Port #"); Serial.println(t); + + for (uint8_t addr = 0; addr<=127; addr++) { + if (addr == TCAADDR) continue; + + Wire.beginTransmission(addr); + if (!Wire.endTransmission()) { + Serial.print("Found I2C 0x"); Serial.println(addr,HEX); + } + } + } + Serial.println("\ndone"); +} + +void loop() +{ +}
\ No newline at end of file |
