Can somebody help me how to lsm9ds1 turn on/off using app inventor?

Hello, everyone
I'm making an application through app inventor that can control LED connected with lsm9ds1
And I'm trying to connect my arduino with my phone and make the button so that if I push the button It can control on/off(using arduino 33 ble sense) But when I click on/off nothing is happen
Can somebody help me how fix? It'll be thankful if someone can help me
And here is arduino code

#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>

BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);

const int ledPin = 13;

void setup() {
  Serial.begin(9600);
  while (!Serial);

  // set LED pin to output mode
  pinMode(ledPin, OUTPUT);
  if (!IMU.begin()) {
        Serial.println("Failed to initialize IMU!");
        while (1);
    }

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting BLE failed!");

    while (1);
  }


  // set advertised local name and service UUID:
  BLE.setLocalName("BLE");
  BLE.setAdvertisedService(ledService);

  // add the characteristic to the service
  ledService.addCharacteristic(switchCharacteristic);

  // add service
  BLE.addService(ledService);

  // set the initial value for the characeristic:
  switchCharacteristic.writeValue(0);

  // start advertising
  BLE.advertise();

  Serial.println("BLE LED Peripheral");
}

 float x, y, z, sum;
void loop() {

  // listen for BLE peripherals to connect:
  BLEDevice central = BLE.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    while (central.connected()) {
  
      if (switchCharacteristic.written()) {
          if(switchCharacteristic.value()==1){
                Serial.println("LSM9DS1 on");
                while(!IMU.accelerationAvailable()) { 
               }
            IMU.readAcceleration(x, y, z);
            
            sum = x + y + z; // X, Y, Z       
              if (sum >= 1.5 || sum <= -1.5) { 
              digitalWrite(ledPin, HIGH); // LED on
              Serial.println(sum);
              delay(500);
              } 
              else if(sum < 1.5 || sum > -1.5){ 
              digitalWrite(ledPin, LOW); //  LED off
              delay(500);
               Serial.println(sum);
              }
          }
        
          else if(switchCharacteristic.value()==2) {                              
            Serial.println(F("LSM9DS1 off"));
            }

    }
  }



    // when the central disconnects, print it out:
    Serial.print(F("Disconnected from central: "));
    Serial.println(central.address());
  }

}