Allan V wrote: ↑
Fri Dec 20, 2019 9:54 pm
I have this code for incrementing a counter each time a GPIO pin is HIGH. I am interested in each time GPIO pin 7 is HIGH:
counter += 1;
counter = counter;
This is written in C, and works for my application.
As with the OP,
this code will always
increment counter as 7 (being as it is not zero) will always evaluate to true, you have to actually test the value of reading a GPIO
otherwise you are just testing the mathematical property that the number 7 is not the number 0.
And well done on necroing a 4 year old thread.
<edited due to split from original thread>