TCA9548A not working with MPU6050 and SSD1306

Hi, I'm trying to run a system here with a rotary encoder, an MPU6050, and an SSD1306 (Circuit diagram below.) The MPU and OLED screen were not working together and after a little bit of research I found that they both need the I2C pins so I got a TCA9548A multiplexer. From all that I read, I should have hooked it up right but neither the MPU or the screen register.
Both the MPU and screen turn on independently. The MPU light is on, and from the debug statements, the prints say the screen is connected but the screen does not turn on. What am I doing wrong?
Thanks

Circuit Diagram

Code

// Load Libraries
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Button.h>

// Create class
#define OLED_RESET -1
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
Adafruit_MPU6050 mpu;
Button calib1(5);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Rotary Encoder Inputs
#define CLK 3
#define DT 4

int counter = 0, currentStateCLK, lastStateCLK, clickNum = 360;
const int trigger = 2, calTrigger = trigger * 3;
String currDir ="", prevDir ="Idle", mode;
int mainWheelRadiusIn = 24; // In
float mainWheelRadiusM = mainWheelRadiusIn * 0.254; // Meters
float angle;
unsigned long currMillis, startTime, finalTime, currDur, btDur, totDur;
const long pauseDuration = 1000; // Miliseconds
const long duration = 2000; // Miliseconds
float angAcceli, angAccelm, angAccelf, angVelf, avgAngAccel;
float maxUserSpeed, currUserSpeed, speedRatio;
int maxMotorSpeed = 1.7, currMotorSpeed;
// Vars for Sensor Data
sensors_event_t a, g, temp;
const int numSamples = 1000; // Number of samples to collect for calibration
const int calibrateDelay = 10; // Delay in milliseconds between samples
float axOffset = 0, ayOffset = 0, azOffset = 0; // Calibration offsets for accelerometer
float axCalibrated = 0, ayCalibrated = 0, azCalibrated = 0;
float tiltX = 0, tiltY = 0, tiltZ = 0;

void calibrateMPU(){
  float axSum = 0, aySum = 0, azSum = 0;
  //robojaxText("Calibrating MPU6050. Please keep the sensor still...", 4, 3, 1, false);
  Serial.println(F("Calibrating MPU6050. Please keep the sensor still..."));
  delay(calibrateDelay); // Initial delay before starting calibration

  for (int i = 0; i < numSamples; i++) {
    // Get new sensor events with the readings
	  mpu.getEvent(&a, &g, &temp);
    axSum += a.acceleration.x;
    aySum += a.acceleration.y;
    azSum += a.acceleration.z;
    delay(calibrateDelay);
  }
  axOffset = axSum / numSamples;
  ayOffset = aySum / numSamples;
  azOffset = azSum / numSamples;

  Serial.println(F("MPU Calibration complete!"));
  Serial.print(F("Accelerometer offsets (X, Y, Z): "));
  Serial.print((axOffset));
  Serial.print(F(", "));
  Serial.print((ayOffset));
  Serial.print(F(", "));
  Serial.println((azOffset));
}

void getMPUData(){
  mpu.getEvent(&a, &g, &temp);
  axCalibrated = a.acceleration.x - axOffset;
  ayCalibrated = a.acceleration.y - ayOffset;
  azCalibrated = a.acceleration.z - azOffset;

  tiltX = atan2(ayCalibrated, azCalibrated) * (180 / PI);
  tiltY = atan2(axCalibrated, azCalibrated) * (180 / PI);
  tiltZ = atan2(ayCalibrated, axCalibrated) * (180 / PI);

  // Print the calculated values
  Serial.print(F("X-Axis Acceleration (m/s^2): "));
  Serial.println((axCalibrated));
  Serial.print(F("Tilt Angle of X-Axis (degrees): "));
  Serial.println((tiltX));
  Serial.print(F("Y-Axis Acceleration (m/s^2): "));
  Serial.println((ayCalibrated));
  Serial.print(F("Tilt Angle of Y-Axis (degrees): "));
  Serial.println((tiltY));
  Serial.print(F("Z-Axis Acceleration (m/s^2): "));
  Serial.println((azCalibrated));
  Serial.print(F("Tilt Angle of Z-Axis (degrees): "));
  Serial.println((tiltZ));
}

void resetCounter(){
  if ((abs(counter) >= trigger) || (currDir != prevDir) || (btDur >= pauseDuration)){
    counter = 0;
    }
  return;
}

float getAngAccel(){   
  getMPUData();
  // Calculation
  float angAccel = axCalibrated / mainWheelRadiusM;

  return angAccel; 
}

float getAngVel( float angAccel, float finalAng){
  float angVel = sqrt(2 * angAccel * (finalAng));
  return angVel;
}

float getLinVel(float angVel, float mainWheelRadiusM){
  float linVel = angVel * mainWheelRadiusM;
  return linVel;
}

/*
 * robojaxText(String text, int x, int y,int size, boolean d)
 * text is the text string to be printed
 * x is the integer x position of text
 * y is the integer y position of text
 * z is the text size, 1, 2, 3 etc
 * d is either "true" or "false". Not sure, use true
 */
void robojaxText(String text, int x, int y, int size, boolean d) {
  display.setTextSize(size);
  display.setTextColor(WHITE);
  display.setCursor(x, y);
  display.println(text);
  if (d) {
    display.display();
  }
}

void calibrateEncoders(){  
  // Serial.println(F(mode));
  readTime();

  // Read the current state of CLK
	currentStateCLK = digitalRead(CLK);

  if (currentStateCLK != lastStateCLK  && currentStateCLK == 1){
	  // If the DT state is different than the CLK state then
	  // the encoder is rotating CCW so decrement
	  if (digitalRead(DT) != currentStateCLK) {
  		counter --;
	 		currDir ="Backward";
       Serial.println((counter));
	  } 
     else {
  		// Encoder is rotating CW so increment
	 		counter ++;
	  	currDir ="Forward";
       Serial.println((counter));
	  }
      angle = counter * (360.00 / clickNum);
      if (currDir != prevDir){
      startTime = currMillis;
       angAcceli = getAngAccel();     
       finalTime = startTime;
     }
     else if (counter == (calTrigger/2)){
       angAccelm = getAngAccel();
     }
     else if (counter <= (calTrigger)){
      finalTime = currMillis;
      angAccelf = getAngAccel();
     }
     else if (btDur >= pauseDuration) {
      Serial.println(F("Please try again..."));
      counter = (trigger + 1);
      resetCounter();
    }
  
    if (counter >= calTrigger)
    {
      avgAngAccel = (angAcceli + angAccelf + angAccelm) / 3;
      angVelf = getAngVel(avgAngAccel, angle);
      maxUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      mode = "Drive";
    }
    else if (counter <= -calTrigger){
      Serial.println(F("Please try again. Push Forward."));
    }
    else{
      Serial.println(F("Keep going"));
    }
    // Put in a slight delay to help debounce the reading
    delay(1);
	  // printREData(currDir, angle);
    resetCounter();
    // Remember last CLK state
    lastStateCLK = currentStateCLK;
    prevDir = currDir;
  }
}

void calibration() {
  /*Serial.println(F("Calibrating MPU, Keep still in"));
  for (int i = 5; i >= 0; --i){
    Serial.println(F(i));
    delay(1000);
  }
  calibrateMPU();
  */
  Serial.println(F("Please Push Forward as hard as you can..."));

  while (mode == "Calibration"){
    calibrateEncoders();
  }
}

void readTime(){
  // Read time
  currMillis = millis();
  btDur = currMillis - finalTime;
  currDur = currMillis - startTime;
  totDur = finalTime - startTime;
}

void willMotorStart(){
  readTime();

  // Read the current state of CLK
	currentStateCLK = digitalRead(CLK);

	// If last and current state of CLK are different, then pulse occurred
	// React to only 1 state change to avoid double count
	if (currentStateCLK != lastStateCLK  && currentStateCLK == 1){

		// If the DT state is different than the CLK state then
		// the encoder is rotating CCW so decrement
		if (digitalRead(DT) != currentStateCLK) {
			counter --;
			currDir ="Backward";
		} 
    else {
			// Encoder is rotating CW so increment
			counter ++;
			currDir ="Forward";
		}

    angle = counter * (360.00 / clickNum);

    if (currDir != prevDir){
      startTime = currMillis;
      angAcceli = getAngAccel();     
      finalTime = startTime;
    }
    else if (counter == abs(trigger/2)){
      angAccelm = getAngAccel();
    }
    else if (counter <= abs(trigger)){
      finalTime = currMillis;
      angAccelf = getAngAccel();
    }
    else if (btDur >= pauseDuration) {
      currDir = 'Idle';
      resetCounter();
	  }
  
    if (counter >= trigger)
    {
      startMotor();
      avgAngAccel = (angAcceli + angAccelf + angAccelm) / 3;
      angVelf = getAngVel(avgAngAccel, angle);
      currUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      speedRatio = currUserSpeed / maxUserSpeed;      
      currMotorSpeed = speedRatio * maxMotorSpeed;
    }
    else if (counter <= -trigger){
     startMotor();
      angVelf = getAngVel(abs(avgAngAccel), abs(angle));
      currUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      speedRatio = currUserSpeed / maxUserSpeed;
      currMotorSpeed = speedRatio * maxMotorSpeed;
    }
    else{
      Serial.println(F("Motor Off"));
    }

    // Put in a slight delay to help debounce the reading
	  delay(1);
		// printREData(currDir, angle);
    resetCounter();
  }
  // Remember last CLK state
	lastStateCLK = currentStateCLK;
  prevDir = currDir;
}

void startMotor(){
  Serial.print(F("Motor started "));
  Serial.println((currDir));
  Serial.print(F("Motor speed: "));
  Serial.println((currMotorSpeed));
  delay(duration);
  resetCounter();
}

// Select I2C BUS
void TCA9548A(uint8_t bus){
  Wire.beginTransmission(0x70);  // TCA9548A address
  Wire.write(1 << bus);          // send byte to select bus
  Wire.endTransmission();
  Serial.println(bus);
}

void setup() {
  // Setup Serial Monitor
	Serial.begin(9600);
  Wire.begin();
	// Set encoder pins as inputs
	pinMode(CLK,INPUT);
	pinMode(DT,INPUT);
  calib1.begin();

  Serial.println(F("pre SCREEN"));
  // Initialize screen
  TCA9548A(0);
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  // Clear the buffer
  display.clearDisplay();
  display.display();
  delay(2000);
  display.clearDisplay();

  Serial.println(F("PreMPU"));
  // Initialize mpu;
  TCA9548A(1);
  if (!mpu.begin()) {
    Serial.println(F("Failed to find MPU6050 chip"));
    while (1) {
      delay(10);
    }
  }
	
	// Read the initial state of CLK
	lastStateCLK = digitalRead(CLK);
  
  Serial.println(F("MPU6050 Found!"));
  //Set accelerometer range and filter bandwidth (optional, based on your requirements)
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
  mpu.setGyroStandby(true, true, true);
  mpu.setTemperatureStandby(true);
  
  mode = "Calibration";
  //calibration();
}

void loop() {
  mode = "Drive";
  readTime();
  willMotorStart();
  if (calib1.pressed()){
    mode = "Calibration";
    calibration();
  }
}

so long as the I2C devices have different addresses you can connect multiple I2C devices to a single I2C interface

do the devices work seperatly?

yes they do. the mpu returns readings when directly connected to the i2c pins and the screen will display the adafruit logo when directly connected. they do not work together

running separately with an i2c scanner, they work on address 60 and address 104 for the screen and mpu respectively. ran the i2c scanner when connected to the multiplexer and got the singular address of 112

There is no reason to use the multiplexer.

Most likely, you are out of memory. The display buffer takes up half of the RAM on the Arduino Uno, but that is not reported among the statistics printing during upload.

Please post the upload memory usage report.

OP is using a 128x32 display, so 512 bytes of ram for the buffer.
I do notice some String variables in the sketch, that can eat up ram too.

Modified the code a little bit

// Load Libraries
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Button.h>

// Create class
#define OLED_RESET -1
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
Adafruit_MPU6050 mpu;
Button calib1(5);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Rotary Encoder Inputs
#define CLK 3
#define DT 4

int counter = 0, currentStateCLK, lastStateCLK, clickNum = 360;
const int trigger = 2, calTrigger = trigger * 3;
String currDir ="", prevDir ="Idle", mode;
int mainWheelRadiusIn = 24; // In
float mainWheelRadiusM = mainWheelRadiusIn * 0.254; // Meters
float angle;
unsigned long currMillis, startTime, finalTime, currDur, btDur, totDur;
const long pauseDuration = 1000; // Miliseconds
const long duration = 2000; // Miliseconds
float angAcceli, angAccelm, angAccelf, angVelf, avgAngAccel;
float maxUserSpeed, currUserSpeed, speedRatio;
int maxMotorSpeed = 1.7, currMotorSpeed;
// Vars for Sensor Data
sensors_event_t a, g, temp;
const int numSamples = 1000; // Number of samples to collect for calibration
const int calibrateDelay = 10; // Delay in milliseconds between samples
float axOffset = 0, ayOffset = 0, azOffset = 0; // Calibration offsets for accelerometer
float axCalibrated = 0, ayCalibrated = 0, azCalibrated = 0;
float tiltX = 0, tiltY = 0, tiltZ = 0;

void calibrateMPU(){
  float axSum = 0, aySum = 0, azSum = 0;
  //robojaxText("Calibrating MPU6050. Please keep the sensor still...", 4, 3, 1, false);
  Serial.println(F("Calibrating MPU6050. Please keep the sensor still..."));
  delay(calibrateDelay); // Initial delay before starting calibration

  for (int i = 0; i < numSamples; i++) {
    // Get new sensor events with the readings
	  mpu.getEvent(&a, &g, &temp);
    axSum += a.acceleration.x;
    aySum += a.acceleration.y;
    azSum += a.acceleration.z;
    delay(calibrateDelay);
  }
  axOffset = axSum / numSamples;
  ayOffset = aySum / numSamples;
  azOffset = azSum / numSamples;

  Serial.println(F("MPU Calibration complete!"));
  Serial.print(F("Accelerometer offsets (X, Y, Z): "));
  Serial.print((axOffset));
  Serial.print(F(", "));
  Serial.print((ayOffset));
  Serial.print(F(", "));
  Serial.println((azOffset));
}

void getMPUData(){
  mpu.getEvent(&a, &g, &temp);
  axCalibrated = a.acceleration.x - axOffset;
  ayCalibrated = a.acceleration.y - ayOffset;
  azCalibrated = a.acceleration.z - azOffset;

  tiltX = atan2(ayCalibrated, azCalibrated) * (180 / PI);
  tiltY = atan2(axCalibrated, azCalibrated) * (180 / PI);
  tiltZ = atan2(ayCalibrated, axCalibrated) * (180 / PI);

  // Print the calculated values
  Serial.print(F("X-Axis Acceleration (m/s^2): "));
  Serial.println((axCalibrated));
  Serial.print(F("Tilt Angle of X-Axis (degrees): "));
  Serial.println((tiltX));
  Serial.print(F("Y-Axis Acceleration (m/s^2): "));
  Serial.println((ayCalibrated));
  Serial.print(F("Tilt Angle of Y-Axis (degrees): "));
  Serial.println((tiltY));
  Serial.print(F("Z-Axis Acceleration (m/s^2): "));
  Serial.println((azCalibrated));
  Serial.print(F("Tilt Angle of Z-Axis (degrees): "));
  Serial.println((tiltZ));
}

void resetCounter(){
  if ((abs(counter) >= trigger) || (currDir != prevDir) || (btDur >= pauseDuration)){
    counter = 0;
    }
  return;
}

float getAngAccel(){   
  getMPUData();
  // Calculation
  float angAccel = axCalibrated / mainWheelRadiusM;

  return angAccel; 
}

float getAngVel( float angAccel, float finalAng){
  float angVel = sqrt(2 * angAccel * (finalAng));
  return angVel;
}

float getLinVel(float angVel, float mainWheelRadiusM){
  float linVel = angVel * mainWheelRadiusM;
  return linVel;
}

void robojaxText(String text, int x, int y, int size, boolean d) {
  display.setTextSize(size);
  display.setTextColor(WHITE);
  display.setCursor(x, y);
  display.println(text);
  if (d) {
    display.display();
  }
}

void calibrateEncoders(){  
  // Serial.println(F(mode));
  readTime();

  // Read the current state of CLK
	currentStateCLK = digitalRead(CLK);

  if (currentStateCLK != lastStateCLK  && currentStateCLK == 1){
	  // If the DT state is different than the CLK state then
	  // the encoder is rotating CCW so decrement
	  if (digitalRead(DT) != currentStateCLK) {
  		counter --;
	 		currDir ="Backward";
       Serial.println((counter));
	  } 
     else {
  		// Encoder is rotating CW so increment
	 		counter ++;
	  	currDir ="Forward";
       Serial.println((counter));
	  }
      angle = counter * (360.00 / clickNum);
      if (currDir != prevDir){
      startTime = currMillis;
       angAcceli = getAngAccel();     
       finalTime = startTime;
     }
     else if (counter == (calTrigger/2)){
       angAccelm = getAngAccel();
     }
     else if (counter <= (calTrigger)){
      finalTime = currMillis;
      angAccelf = getAngAccel();
     }
     else if (btDur >= pauseDuration) {
      Serial.println(F("Please try again..."));
      counter = (trigger + 1);
      resetCounter();
    }
  
    if (counter >= calTrigger)
    {
      avgAngAccel = (angAcceli + angAccelf + angAccelm) / 3;
      angVelf = getAngVel(avgAngAccel, angle);
      maxUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      mode = "Drive";
    }
    else if (counter <= -calTrigger){
      Serial.println(F("Please try again. Push Forward."));
    }
    else{
      Serial.println(F("Keep going"));
    }
    // Put in a slight delay to help debounce the reading
    delay(1);
	  // printREData(currDir, angle);
    resetCounter();
    // Remember last CLK state
    lastStateCLK = currentStateCLK;
    prevDir = currDir;
  }
}

void calibration() {
  /*Serial.println(F("Calibrating MPU, Keep still in"));
  for (int i = 5; i >= 0; --i){
    Serial.println(F(i));
    delay(1000);
  }
  calibrateMPU();
  */
  Serial.println(F("Please Push Forward as hard as you can..."));

  while (mode == "Calibration"){
    calibrateEncoders();
  }
}

void readTime(){
  // Read time
  currMillis = millis();
  btDur = currMillis - finalTime;
  currDur = currMillis - startTime;
  totDur = finalTime - startTime;
}

void willMotorStart(){
  readTime();

  // Read the current state of CLK
	currentStateCLK = digitalRead(CLK);

	// If last and current state of CLK are different, then pulse occurred
	// React to only 1 state change to avoid double count
	if (currentStateCLK != lastStateCLK  && currentStateCLK == 1){

		// If the DT state is different than the CLK state then
		// the encoder is rotating CCW so decrement
		if (digitalRead(DT) != currentStateCLK) {
			counter --;
			currDir ="Backward";
		} 
    else {
			// Encoder is rotating CW so increment
			counter ++;
			currDir ="Forward";
		}

    angle = counter * (360.00 / clickNum);

    if (currDir != prevDir){
      startTime = currMillis;
      angAcceli = getAngAccel();     
      finalTime = startTime;
    }
    else if (counter == abs(trigger/2)){
      angAccelm = getAngAccel();
    }
    else if (counter <= abs(trigger)){
      finalTime = currMillis;
      angAccelf = getAngAccel();
    }
    else if (btDur >= pauseDuration) {
      currDir = 'Idle';
      resetCounter();
	  }
  
    if (counter >= trigger)
    {
      startMotor();
      avgAngAccel = (angAcceli + angAccelf + angAccelm) / 3;
      angVelf = getAngVel(avgAngAccel, angle);
      currUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      speedRatio = currUserSpeed / maxUserSpeed;      
      currMotorSpeed = speedRatio * maxMotorSpeed;
    }
    else if (counter <= -trigger){
     startMotor();
      angVelf = getAngVel(abs(avgAngAccel), abs(angle));
      currUserSpeed = getLinVel(angVelf, mainWheelRadiusM);
      speedRatio = currUserSpeed / maxUserSpeed;
      currMotorSpeed = speedRatio * maxMotorSpeed;
    }
    else{
      Serial.println(F("Motor Off"));
    }

    // Put in a slight delay to help debounce the reading
	  delay(1);
		// printREData(currDir, angle);
    resetCounter();
  }
  // Remember last CLK state
	lastStateCLK = currentStateCLK;
  prevDir = currDir;
}

void startMotor(){
  Serial.print(F("Motor started "));
  Serial.println((currDir));
  Serial.print(F("Motor speed: "));
  Serial.println((currMotorSpeed));
  delay(duration);
  resetCounter();
}

// Select I2C BUS
void TCA9548A(uint8_t bus){
  Wire.beginTransmission(0x70);  // TCA9548A address
  Wire.write(1 << bus);          // send byte to select bus
  Wire.endTransmission();
  Serial.println(bus);
}

/**
 * I2CScanner.ino -- I2C bus scanner for Arduino
 * 2009,2014, Tod E. Kurt, http://todbot.com/blog/
**/

#include "Wire.h"
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}

// Scan the I2C bus between addresses from_addr and to_addr.
// On each address, call the callback function with the address and result.
// If result==0, address was found, otherwise, address wasn't found
// (can use result to potentially get other status on the I2C bus, see twi.c)
// Assumes Wire.begin() has already been called
void scanI2CBus(byte from_addr, byte to_addr, 
                void(*callback)(byte address, byte result) ) 
{
  byte rc;
  byte data = 0; // not used, just an address to feed to twi_writeTo()
  for( byte addr = from_addr; addr <= to_addr; addr++ ) {
    rc = twi_writeTo(addr, &data, 0, 1, 0);
    callback( addr, rc );
  }
}

// Called when address is found in scanI2CBus()
// Feel free to change this as needed
// (like adding I2C comm code to figure out what kind of I2C device is there)
void scanFunc( byte addr, byte result ) {
  Serial.print("addr: ");
  Serial.print(addr,DEC);
  Serial.print( (result==0) ? " found!":"       ");
  Serial.print( (addr%4) ? "\t":"\n");
}


byte start_address = 8;       // lower addresses are reserved to prevent conflicts with other protocols
byte end_address = 119;       // higher addresses unlock other modes, like 10-bit addressing

void setup() {
  // Setup Serial Monitor
	Serial.begin(9600);
  Wire.begin();
  mpu.begin();
	// Set encoder pins as inputs
	pinMode(CLK,INPUT);
	pinMode(DT,INPUT);
  calib1.begin();
  TCA9548A(112);
  Serial.println(F("pre SCREEN"));
  // Initialize screen
  TCA9548A(60);
  if(!display.begin(0x01, 0x60)) {
    Serial.println(F("SSD1306 allocation failed"));
    while (1) {
      delay(10);
    }
  }
  // Clear the buffer
  display.clearDisplay();
  display.display();
  delay(2000);
  display.clearDisplay();

  Serial.println(F("PreMPU"));
  // Initialize mpu;
  TCA9548A(1);
  if (!mpu.begin()) {
    Serial.println(F("Failed to find MPU6050 chip"));
    while (1) {
      delay(10);
    }
  }
	
	// Read the initial state of CLK
	lastStateCLK = digitalRead(CLK);
  
  Serial.println(F("MPU6050 Found!"));
  //Set accelerometer range and filter bandwidth (optional, based on your requirements)
  mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
  mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
  mpu.setGyroStandby(true, true, true);
  mpu.setTemperatureStandby(true);
  
  mode = "Calibration";
  //calibration();

    Serial.println("\nI2CScanner ready!");

    Serial.print("starting scanning of I2C bus from ");
    Serial.print(start_address,DEC);
    Serial.print(" to ");
    Serial.print(end_address,DEC);
    Serial.println("...");

    // start the scan, will call "scanFunc()" on result from each address
    scanI2CBus( start_address, end_address, scanFunc );

    Serial.println("\ndone");
    
    // Set pin mode so the loop code works ( Not required for the functionality)
    pinMode(13, OUTPUT);
}

void loop() {
  mode = "Drive";
  readTime();
  willMotorStart();
  if (calib1.pressed()){
    mode = "Calibration";
    calibration();
  }
     // Nothing to do here, so we'll just blink the built-in LED
    digitalWrite(13,HIGH);
    delay(300);
    digitalWrite(13,LOW);
    delay(300);
}

Memory output is

Sketch uses 27310 bytes (84%) of program storage space. Maximum is 32256 bytes. Global variables use 1016 bytes (49%) of dynamic memory, leaving 1032 bytes for local variables. Maximum is 2048 bytes.

Print is

112
pre SCREEN
60
PreMPU
1
MPU6050 Found!

I2CScanner ready!
starting scanning of I2C bus from 8 to 119...
addr: 8
addr: 9 addr: 10 addr: 11 addr: 12
addr: 13 addr: 14 addr: 15 addr: 16

addr: 17 addr: 18 addr: 19 addr: 20
addr: 21 addr: 22 addr: 23 addr: 24
addr: 25 addr: 26 addr: 27 addr: 28
addr: 29 addr: 30 addr: 31 addr: 32
addr: 33 addr: 34 addr: 35 addr: 36
addr: 37 addr: 38 addr: 39 addr: 40
addr: 41 addr: 42 addr: 43 addr: 44
addr: 45 addr: 46 addr: 47 addr: 48
addr: 49 addr: 50 addr: 51 addr: 52
addr: 53 addr: 54 addr: 55 addr: 56
addr: 57 addr: 58 addr: 59 addr: 60
addr: 61 addr: 62 addr: 63 addr: 64
addr: 65 addr: 66 addr: 67 addr: 68
addr: 69 addr: 70 addr: 71 addr: 72
addr: 73 addr: 74 addr: 75 addr: 76
addr: 77 addr: 78 addr: 79 addr: 80
addr: 81 addr: 82 addr: 83 addr: 84
addr: 85 addr: 86 addr: 87 addr: 88
addr: 89 addr: 90 addr: 91 addr: 92
addr: 93 addr: 94 addr: 95 addr: 96
addr: 97 addr: 98 addr: 99 addr: 100
addr: 101 addr: 102 addr: 103 addr: 104 found!
addr: 105 addr: 106 addr: 107 addr: 108
addr: 109 addr: 110 addr: 111 addr: 112 found!
addr: 113 addr: 114 addr: 115 addr: 116
addr: 117 addr: 118 addr: 119
done
Please Push Forward as hard as you can...

it registers the MPU and the multiplexer but not the screen and it should have more than 512 bytes of memory free

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.