Create some kind of Radar with VL53L1X

I wanted to create some kind of radar with VL53L1X Sensor from pololu. I attach that sensor to Analog Servo S-0307 so I can rotate it.
I used arduino NANO 33 IOT, Library VL53L1X from Pololu and Servo library.
I have tested first the code without the servo and I can see in the serial monitor my Range. Likewise I also test the servo rotation without the Range sensor and it rotate. But then when I combine both, the I didn't see any Range in my Serial Monitor, nor the servo Rotate.
Could anyone please help me? where did I do wrong or some other suggestion? or may be some link where I could see the code of similar project ?
Thank You

#include "Wire.h"
#include "VL53L1X.h"
#include "Servo.h"

Servo myservo;
VL53L1X sensor;

int pos = 93; // Horizontal Position

void setup()
{
  myservo.attach(2);
  myservo.write(pos);
  Serial.begin(115200);

  Wire.begin();
  Wire.setClock(400000); // use 400 kHz I2C

  sensor.setTimeout(500);

  if (!sensor.init())
  {
    Serial.println("Failed to detect and initialize sensor!");
    while (1);
  }

  sensor.setDistanceMode(VL53L1X::Long);
  sensor.setMeasurementTimingBudget(50000);

  sensor.startContinuous(50);
}

void loop()
{
  static bool dir = false;
  myservo.write(pos);
  sensor.read();
  // Rotate to +45 and back to -45 from Horizontal Pos 93
  if (dir) {
      pos++;
      if (pos >= 138) {
        dir = !dir;
      }

    } else {
      pos--;
      if (pos <= 48) {
        dir = !dir;
      }
    }
  Serial.print("\tPos");
  Serial.print(pos);
  Serial.print("\tRange: ");
  Serial.print(sensor.ranging_data.range_mm);
  Serial.println();

  delay(15);
}[code/]

Are you using a separate power supply for the servo, as required? Don't forget to connect the grounds.

No, at the moment I didn't use any separate power supply but later I will use a battery. I'm pretty sure my circuit is not the problem because I have tested its functionality (Only Sensor, and then Only Servo) and its worked. Only after I combine like the code above it didn't work

You will damage or destroy the Arduino, attempting to power a servo from +5V. Fix that first.

Sorry, I didn't quite understand what you mean by attempting to power a servo from +5V? My Arduino Nano 33 Iot are working in 3.3V and when I test the sweep example or my own code without any separate power supply its always work (power supply from 3.3V Arduino).

Please re-read reply #1.

Good luck with your project.

Did you find a solution to your problem?

I've attached a VL53L1X and a servo to a robot where the VL53L1X is powered by the Arduino and the servo is powered by a 5V buck converter capable of handling 3A. Both are connected to a battery.

I can get the sensor and the servo to work independently however when the myServo.attach(pin) function is called the VL53L1X stops working.

I know this because I initialised the VL53L1X then put a 5 second delay in the code to give me time to look at the sensors emitted IR through my camera then the myServo.attach() function was called and the IR emitter stopped emitting. I have my servo attached to pin 11 on the Arduino and I'm using a Arduino Pro Mini.

I suspect that the servo library is conflicting with either the Wire library or the VL53L1X's library. Like you I'm also using the polou library.