I have set up a digital intrrupt as described here (https://industruino.com/forum/help-1/question/indio-digital-input-interrupt-usage-31) and it works fine on its own. Now, I am trying to implement it in a project where I also have other digital inputs to read (simple on/off state). I set up the interrupt on pin 7 with a counter to keep track of pin state changes: I am taking readings from a pulse water meter so every change in pin state equals to a certain amount of water passing through the meter. However I am getting random readings (the counter is even getting negative numbers?!?) whenever the other digital pins state changes. Is it possible that the interrupt is picking up noise? Is there a way to fix it?
Thank you in advance.
The interrupt of the 24V side will trigger when a change on any of the 8 input or outputs occurs. In your code you should deduct or turn off the interrupt counter when you are changing the state of an output or another pin but 7 changes. The negative numbers you are getting are probably an overflow of your integer, you should define your counter as an "unsigned int" or "unsigned long" to avoid the negative numbers.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!