I'm building a miniature pinball machine and I am attempting to use an infrared reflector sensor (QRE1113) to detect when the ball rolls over it (I got the original idea from Ben Heck's videos).
In my testing the sensor does respond adequately to a ball rolling over it, and it's easy to make this determination through the Arduino analog input.
However a pinball machine has way more rollover sensors than the Arduino has analog inputs (final playfield will have ~10-20 rollovers).
My Arduino code doesn't need to know the analog value of the sensor, all it needs to know is whether the value has dropped below a certain threshold meaning a ball is on top of the sensor.
So ideally I would like to convert this analog value to a low or high depending on whether that threshold has been reached, and to then send that result to a digital pin instead of an analog one.
I sort of solved this problem by hooking the sensor up to a digital pin, but using a potentiometer to adjust the sensitivity so that the threshold voltage I want to detect happens to line up with the threshold of what Arduino considers to be high or low.
This is essentially identical to this schematic (but I'm NOT using the sparkfun breakout board, I'm using the bare sensor): http://cdn.sparkfun.com/datasheets/Sensors/Infrared/QRE1113%20Line%20Sensor%20Breakout%20-%20Analog.pdf
The only difference from that schematic is that instead of the 10K resistor I have a 1M resistor and a 500K potentiometer in series in place of where the 10K resistor would be (I think their schematic has a mistake, a 10K resistor gave me terrible results and through trial and error I found 1M works best).
This solution works but it feels cludgy because I'm not actually generating a proper 3.3V HIGH or 0V LOW signal and instead sending an analog signal that just so happens to match up with what Arduino considers the fringes of a high or a low.
Is there a better more "official" way to do this instead of my hack that would allow me to send 0V or 3.3V to the Arduino digital pin based on the analog sensor reaching a certain threshold (ideally adjustable since it takes some trial and error to get the right sensitivity).
I'm building this machine mostly to learn electronics so the "lower level" the solution the better. I know there are ADC boards will expand how many analog inputs I have via "magic", but it would be way more satisfying to build something out of basic components that I can understand.
PS: I'm mostly a software guy. Building electronics circuits is new to me so if I'm thinking about the problem all wrong let me know as well.