My program has a hardware interrupt to digital pin 2, it is an IR obstacle detection sensor which gives “open collector” signal. My program is executing an array — “for” loop. At some point it has to wait for the input from the IR sensor, so I am using a “while” loop to pause and wait for the input.
When the program gets the signal from the sensor at which point the interrupt occurs, the program collects the data (millis) and goes on for another round. Everything works fine, but I would like to limit the time that the program is waiting for the interrupt signal, let’s say to 5 or 10 seconds. I do not want it to just sit there forever if the signal is not coming for some reason. So what I am trying to do is to trigger the same interrupt pin (2) by another digital pin. I set this pin (7) on OUTPUT wrote a little “if-then” statement so it will go HIGH when the time is up and connected this pin (7) to pin 2.
The scheme works partially. When the pins are connected and the time limit is reached the pin 2 gets signal and gets triggered. But the IR signal seems to be disabled and not functioning while it is waiting for the time limit. I tried to connect pull-up and pull-down resistors to no avail. It seems that when the pins are linked the IR signal disappears. I do not even get any voltage readings on that wire. If I disconnect the pins the IR signal works again and I get voltage readings on the wire.
Can anyone tell me what is going on and how can I make it work. Is even possible? Or what I have concocted is just plain silly?