Search
 
SCRIPT & CODE EXAMPLE
 

CPP

TCA9548 I2CScanner Arduino

/**
 * 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("
TCAScanner 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("
done");
}

void loop() 
{
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ over load oprator to print variable of clas 
Cpp :: turn it codechef solution in c++ 
Cpp :: codeforces problem 1700A solution in c++ 
Cpp :: qpushbutton clicked connect c++ 
Cpp :: c++ require keyword 
Cpp :: ue4 c++ enum variable declaration 
Cpp :: library management system project in c++ using array 
Cpp :: convert into acsii c++ 
Cpp :: find node from pos linkedlist c++ 
Cpp :: c++ int max value 
Cpp :: tan trigonometric function 
Cpp :: get shape of eigen matrix 
Cpp :: C++ meaning :: 
Cpp :: how to calculate 2^7 in cpp code 
Cpp :: c++ poitner 
Cpp :: how to check private messages on reddit 
Cpp :: delete an dynamic array 
Cpp :: fast scan in c++ 
Cpp :: high school hacking competition 
Cpp :: qt unhandled exception handler 
Cpp :: c++ 
Cpp :: c++ program 
Cpp :: c++ find with predicat 
Cpp :: split the array there is an array val of n integers . A good subarray is defined as 
Cpp :: clang does not recognize std::cout 
Cpp :: this is my p phone number in punjabi 
Cpp :: construct string with repeat limit 
Cpp :: c++ programming 
Cpp :: patterns in c++ 
Cpp :: geekforgeeks stacks 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =