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

Thread Starter

Cris56

Joined Jan 26, 2021
8
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
:D


This is the code I used, it's from this website https://www.elithecomputerguy.com/2019/06/ir-sensor-digital-output-on-arduino/
#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);
}
 

Attachments

djsfantasi

Joined Apr 11, 2010
9,156
Pin 6 should be connected to ground. And pin 5 should be connected to pin 7. The input pins are floating and may be responding to ghost inputs, affecting the operation of the comparator in use.
 
Last edited:

kaindub

Joined Oct 28, 2019
125
The IR circuit is very crude .
Stray IR will affect the performance causing false triggering.
Is the output of the op amp high or low when nothing is in front of the transmitter and detector.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

The sensor is quite different to the one in the picture in the first post.
VCNT2020.png

What is the used supply voltage?
The sensitivity of the sensor may be to high:
vcnt2020_crt.png

Bertus
 

Attachments

sghioto

Joined Dec 31, 2017
5,378
Actually you can test the circuit by removing the connection on the sensor connected to the 10K resistor.
Set VR1 in about the middle. If the circuit is good the LED should be OFF.
If you short that connection to ground the LED will always be ON.
1611936428459.png
 

Thread Starter

Cris56

Joined Jan 26, 2021
8
UPDATE

After some wiring check and I ditched the 104 capacitor. The circuit kind of works.
When I rotate the potentiometer, at some point it says "STOP" even though nothing is in front and when I rotate back it says "All Clear"

In another test, I rotated the potentiometer until it says "All Clear", I placed a white paper in front of the sensor and rotated the potentiometer until it said "STOP". After that, I took the paper out but the message didn't change to "All Clear"

I did the same test with a different sensor, the ITR20001/T but now apparently I can change the value only by rotating the potentiometer but the sensors are not affecting anything
 

Thread Starter

Cris56

Joined Jan 26, 2021
8
FINAL UPDATE

I made it work!
Basically, I just removed the potentiometer and connected the pin 2 to the ground and now it works without a problem :)

Thank you guys so much!!!!!!!!!!!!!!!!!!!!!
 
Top