I made a project where I want to detect rotations of a disk.
The disk has a black marking and to detect this I use a line detector, QRB1114 (basically an IR LED and phototransistor in a house).
Because I want to integrate this with a routine that use delay(), the sensor is used to trigger an interrupt, in that way I always catch the black mark, even when noop’ing away.
However, connecting an “analog” sensor to a digital pin is somewhat challenging, when you don’t want to use additional circuitry.
When the line comes flying by the interrupt is triggered 40+ times due to the analog value jumping up and down between the logical high and low value before settling.
To debug what the sensor was seeing I decided to connect the sensor to an analog input and read the value out on an LCD. However by doing this the jitter seem to completely stop.
About the circuit:
QRB collector is pulled high with 5.6kohm and connected to pin2 and A3.
The analog value is ~40 (~0.2V) when no mark is present and ~600 (2.9V) when line is present (in a 0-1023 range).
This is far from optimal, as high level should be close(er) to 5V, however it seems to work now when pin2 and A3 are directly connected.
Could anybody tell me why this is the case - that the jitter stops when pin2 and A3 is connected together?
And how to (easily) obtain same result without the use of A3?