What Library to use to utilize a waveshare infrared reflective sensor?

Greetings!

I'm trying to get my Waveshare Infrared Reflective Sensor to send distance information to an Arduino UNO via a digital input to judge distance.

What library should I use with the project? I have seen several suggestions for various IR sensors but they all were for specific sensors, none matching the Waveshare that I have.

Any suggestions would be greatly appreciated.

Sign--
Ben

It's a proximity sensor so it won't return "distance" per se, more like "near" or "not near."

The demo code they show in their Infrared Proximity Sensor Demo.7z package is very, very simplistic:

int Obstacles_din=2;
int Obstacles_ain=A0;
int ad_value;
void setup()
{
  pinMode(Obstacles_din,INPUT);
  pinMode(Obstacles_ain,INPUT);
  Serial.begin(9600);
}
void loop()
{
  ad_value=analogRead(Obstacles_ain);
  if(digitalRead(Obstacles_din)==LOW)
  {
    Serial.println("Near the Obstacles");
    Serial.println(ad_value);
  }
  else
  {
    Serial.println("Far the Obstacles");
  }
  delay(500);
}

Ah, thank you for your quick response, it'll save me a lot of time and hassle not trying to get it to tell me an actual distance.

Though I am curious as to why the sensor has a digital output if it only were to have a high/low analog state?

Sad it didn't work the way I want but this is a learning experience for me.

Thanks! :slightly_smiling_face:

The store page:

Links to the wiki page:

You can use the analog output for rough distance/reflectivity sensing. The digital output is a HIGH/LOW signal with a threshold adjustable with the potentiometer.

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