General: i have to count two kinds of pulses with 2 Photointerrupters at different Times. i count the pulses with the internal Timer1 / TCNT1 ( i will post some simple script later ) at Pin 5 corresponding to ICP1. I use Photointerrupter Typ GP1A53HR that has a IR-Led as Input and a Schmitt-Trigger as output. This offers less sensitivity for noise and works well. Problem: As the Microcontroller only has 3 Timers i want to have the possibility to count either the impulses of PhotoInterrupterA or B. I have some Pins left, so i can connect the IR-Leds and also the Output Schmitt-Triggers to other Pins to turn them on/off. But i haven t found a setup that allows me to disable / enable the unused / used Photointerrupter. (As soon as i connect both outputs i will not record the state of the active one ) Any suggestions, e.g. a intelligent Resistor setup or a software/Pin-based solution?
Ok the Pin-intensiv-solution works like this: the Ground/0V and the Vcc/5V power of each Photointerrupter is connected to a pin (4 Pins alltogether). Turn 0V to LOW and 5V to HIGH will enable and turn both to HIGH will disable the Photointerrupter. But i still think there is a much simpler solution with some resistors and only use of 2 Pins.
you will find the code-snippets i was refering above here:
Use a photointerrupter as external clock at T1 and count the slots passed:
you also might be interessted in:
How to set prescalers, some background on bit-Math, how to control a strong motor:
please do NOT post comments / improvements here, feel free to email (contact in articles) thanks.