Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 2

LidarLite 3V with Arduino Nano Relay Control

Solved! Go to Solution.

Hi,

I am working on a project setting up a LidarLite 3V to activate a relay at a predetermined distance. I have constructed several sketches that will compile but my understanding of the Lidar input value is lacking. Being connected via I2C where/how does one interpret the distance in order to activate a simple relay? The following code was the last "wild hair" reach at triggering the relay but it will reflect the premise of what I am attempting to achieve. The Lidar unit is working perfectly with this code, as mentioned before it does compile with no errors on the Arduino IDE.

#include <Wire.h>
#include <LIDARLite.h>
#define SLAVE_ADDRESS 0x0f
LIDARLite lidar3v;
int reading = SLAVE_ADDRESS;

int relayCH1 = 11;

void setup()
{
  Serial.begin(115200);

  pinMode(relayCH1, OUTPUT);

  lidar3v.begin(0,true);

  lidar3v.configure(3);
}

void loop()
{

  int distance = reading;
  Serial.println(lidar3v.distance(0));


  {
    Serial.println(lidar3v.distance(false));

    {
      if (distance <= 50) {
        digitalWrite(11, HIGH);
      } else {
        digitalWrite(11, LOW);

      }
    }
  }
}

I am not asking for anyone to write the code for me, just need to understand how/where the distance value from a lidar unit is usable inside the program. Is it from an 0xXX address, digitalRead, analogRead? I have tried many combinations.

Thank you for your time,

James

1 Reply
Solution
Copilot Lvl 2
Message 2 of 2

Re: LidarLite 3V with Arduino Nano Relay Control

All is well now, found a solution. A special "Thank You" to everyone that was considering assisting me on this.