Sylanvys:
Hello guys. I have a code as follow. I need some suggestion on how to improve it. My systems has 1 stepper, 1 servo motor, and 1 lidar sensor.static unsigned long timer = 0;
unsigned long interval = 10; //1000/10 = 100 samples every second
if (millis() - timer > interval)
{
timer = millis();
myLidarLite.beginContinuous(false,0x13,0xff,0x62); //100Hz, infinite reading
distance = myLidarLite.distanceContinuous();...
stupid question:sorry I have not used this system before either but you want so sample (read distance) every 10ms... so why are you use infinite reading instead of requesting only one read every 10ms ie "myLidarLite.beginContinuous(false,0x13,0x01,0x62); " instead of "myLidarLite.beginContinuous(false,0x13,0xff,0x62);"?
either that or "myLidarLite.beginContinuous(false,0x13,0xff,0x62); //100Hz, infinite reading" should be moved to setup as this looks like an mode initialisation for the LIDAR and does not need to be called every time