LIDAR scanner and Arduino board

After changing the baud rate and simplifying the code with GTP.
We tested the wiring, power supply from the laptop port, and connection between Mega and Laptop is all right.
Sleep tight Tom.
Now the code is



#include <RPLidar.h>

RPLidar lidar;

void setup() {
  Serial.begin(115200);
  Serial1.begin(460800);
  delay(1000);
  Serial.println("Initializing RPLIDAR...");

  // Try to detect RPLIDAR...
  if (lidar.begin(Serial1)) {
    Serial.println("RPLIDAR detected!");
  } else {
    Serial.println("Failed to connect to RPLIDAR");
  }
}

void loop() {
  // Read data from RPLIDAR
  if (lidar.waitPoint()) {
    float distance = lidar.getCurrentPoint().distance; // Distance in mm
    float angle = lidar.getCurrentPoint().angle; // Angle in degrees
    Serial.print("Distance: ");
    Serial.print(distance);
    Serial.print(" mm, Angle: ");
    Serial.println(angle);
  }
}


Did you manage to get it working? I want to do the exact same thing.
I ran this code, but it only showed the message "RPLIDAR not detected. Trying again..."

Hi, I just got a Slamtec C1M1 V2, tryinng to get it going. Did you solve the issue?

thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.