Ir obstacle avoidance sensor always detecting something in front even though there's nothing

Here is the code I used. I've tried adjusting the potentiometers on the sensor but still no success.
I've tried different code online and still have the same problem. Also tried with different arduino boards (uno and mega) and still no success.

int LED = 13;

int isObstaclePin = 2;  

int isObstacle = HIGH;  

void setup() {

  pinMode(LED, OUTPUT);

  pinMode(isObstaclePin, INPUT);

  Serial.begin(9600);  

}

void loop() {

  isObstacle = digitalRead(isObstaclePin);

  if (isObstacle == LOW)

  {

    Serial.println("Obstacle");

    digitalWrite(LED, HIGH);

  }

  else

  {

    Serial.println("clear");

    digitalWrite(LED, LOW);

  }

  delay(200);

}

What sensor?

IR obstacle avoidance sensor, Duinotech.

Link thereto?

Maybe you need to use INPUT_PULLUP in pinMode?

Presence of potentiometers makes me wonder if it's pir?

FZD6OSMIJ4MK0GZ

Hi,
Can you please post a circuit diagram of your project?
An image of your project would be good too.

Tom.. :smiley: :+1: :coffee: :australia:

... and also say if INPUT_PULLUP helped @jayza The specs in the link posted just say the sensor is active low, but doesn't say if it explicitly makes the output high otherwise or if it's open collector in which case you need to provide the high.

You're not using the enable pin in your code, so check the enable jumper position: reference

Hi,
This may help;
http://irsensor.wizecode.com/
It includes instructions on how to set the module up.
I particular the frequency pot to set the Tx IR frequency at 38KHz that the IR Rx is tuned for.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

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