hoping someone can help me

first and foremost, thank you in advance for any and all help. i am new to arduino, so i dont know a lot of the basics.

i have a arduino connected to a micro lidar sensor (VL53L0X) that is suppose to trigger a robotic arm to perform an action sequence when an object gets within x range to the sensor.

my program seems to run fine sometimes. other times it repeatedly loop triggers my robotic arm when the sensor isn't tripped. other times it runs fine then just stops triggering the arm altogether until i restart it.

why is it doing this?

code is as follows

#include <LobotServoController.h>
#include "Adafruit_VL53L0X.h"

#define rxPin 10
#define txPin 11

Adafruit_VL53L0X lox = Adafruit_VL53L0X();

SoftwareSerial mySerial(rxPin, txPin);
LobotServoController myse(mySerial);

void setup() {
pinMode(13,OUTPUT);
mySerial.begin(9600); //opens software serial port, sets data rate to 9600 bps
Serial.begin(9600);
digitalWrite(13,HIGH);

Serial.begin(115200);

// wait until serial port opens for native USB devices
while (! Serial) {
delay(1);
}

Serial.println("Adafruit VL53L0X test");
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
// power
Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
VL53L0X_RangingMeasurementData_t measure;

Serial.print("Reading a measurement... ");
lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

if (measure.RangeStatus != 4) { // phase failures have incorrect data

Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);

if (measure.RangeMilliMeter < 40) {

myse.runActionGroup(6,1); //loop run No.100 action group
delay(5000);
}
} else {
Serial.println(" out of range ");
}

}

What do your serial prints tell you when the arm is working ok? How about when it's acting up?

The monitor for the distance sensor will sometimes keep reading the same distance 95 (200 on repeat) or sometimes doesn't read when something get close to it (continues reading 300+)

If your talking about the the tx/rx serial port reads from arduino to the arm. I'm not sure how to view those. How do I read that information?

Again, I am very new to this. thank you for your reply

i just realized i had serial.begin twice with two different values. could this be the issue here?

Quite likely, it depends on the speed of whatever it is connected to. Make up your mind about which one you want. The last one is the one it is working at. No harm done.