I am trying to create a comparator on the Teensy 3.2 to convert an IR receiving diode signal from analog to digital. Currently I am using an op amp, but that takes extra space and extra power, both of which should be limited for my application. The circuit is below (instead of putting output to LED, it goes to pin on microcontroller)
I'm still new to microcontrollers, and tried reading the reference manual for the microcontroller. I can see it has this function, but I'm not sure how to implement it. I thought their might be prebuilt libraries for the Arduino IDE, but had trouble finding the right thing.
The IR system is measuring the rotation of a propeller, and I would just like to have the system count how many times a blade blocks light from the emitter by looking at the falling edge of the IR receiver signal after digitizing. (In the end, too, I plan to power both off of a PWM with as low as possible duty cycle. This could affect how I do the counting in the end)
For a comparator, do I need to create the signal to compare to with a resistor divider? How do I know which teensy pins correspond to the comparator input signal? Could I set it digitally in some way in the MCU registers, avoiding the need for more circuit parts?
Does the output of the comparator come from a certain pin? Can I set it up to cause in interrupt instead and not use that pin, so that it executes code in the program and thats it? Is there a way to make the comparator output stay in a fixed state when the LEDs are both powered off?
Thanks for the advice!