HG-C Panasonic Laser

Hi

I purchased the HG-C1100 and I am trying to work it with arduino nano.
i watched the youtube of "HG-C Panasonic Laser Data aquisition with Arduino and android app" on youtube: https://www.youtube.com/watch?v=hLO2mChToHs&t=83s
it doesn't show the complete code of the arduino.
I searched on google and youtube and i couldn't find an example code for the HG-C1100.
I would appreciate it if anyone could send me an example code for the arduino or
if you can direct me to a tutorial.

Thanks in advance
Adi Franco
Laser Cat

See if this link helps: HG-C 1100 sensor - #12 by TomGeorge

Hi Adi,

The code is very simple . its a analog sensor which outputs 0-5V .

Use .

AnalogRead(Sensor analog pin)

The grey wire from the sensor is the analog pin that outputs voltage .

Make sure the Output is set to voltage in the sensor because arduino can only read voltage .

Below functions are used to convert analog reading to distance .

int AnalogRead(int Pinnumber) {
  int RawSensorData;
  RawSensorData = analogRead(Pinnumber);

  if (RawSensorData >= 1020) {
    return 0;
  } else {
    return RawSensorData;
  }
}


//Converts voltage to distance
float GetDistance(int RawSensorData) {
  float distance;

  //Convert from voltage to Distance

  if (RawSensorData != 0) {
    distance = 135.000 - (RawSensorData / 1023.0) * (135.000 - 65.000);

    return distance;
  } else {
    return 0;
  }
}

This code should work considering the sensor detection range is from 65 to 135 mm .