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 11Adafruit_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 ");
}}