VCNT2020 IR sensor - Digital output. Serial monitor shows ''0'' only

Hi everyone,

There are boards with IR sensors on the market that looks like this: the IR.PNG picture

I have all the components to build one myself with the Arduino Uno, VCNT2020 sensor and LM393. The schematic is the example.jpg picture (it's the schematic of the sensors on the market)
The picture LM393.png shows what pins I connected to the LM393.

The problem is that in the serial monitor, the display message is ''STOP'' but nothing else is in front of the sensor.
Even if I rotate the potentiometer, nothing changes.

I disassembled and reassembled everything a couple of times because I thought that I didn't connect something but it led to the same result.

Any help will be much appreciated :smiley:

This is the code I used, it's from this website IR Sensor Digital Output on Arduino – Eli the Computer Guy

#define IR 8

int Obstacle;

void setup() {
  pinMode(IR, INPUT);
  Serial.begin(9600);
}

void loop() {
  Obstacle = digitalRead(IR);

  if (Obstacle == LOW) {
    Serial.println("STOP");
  }
 else {
   Serial.println("All Clear");

  }
  delay(500);
}

IR.PNG

IR.PNG

Does the picture actually show your board? If this isn't the case, post a sharp picture of your setup!

My guess is a hardware problem (it doesn't have to be the circuitry!), for example a direct illumination of the sensor by the LED.

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