The results I am getting is that whenever the Interrupt is triggered it is run just one time, I am sure that I am not getting stuck on the interrupts because, the code on the loop keeps working even after I had executed the interrupts.
Two cases.
If digitalRead(9) returns zero, then the ~ operator changes it to all ones (0xFFFF).
If digitalRead(9) returns one, then the ~ operator changes it to 0xFFFE.
Either way, t will be set to true because both 0xFFFF and 0xFFFE are non-zero.
What are you actually trying to accomplish with the ~ operator?
Two cases.
If digitalRead(9) returns zero, then the ~ operator changes it to all ones (0xFFFF).
If digitalRead(9) returns one, then the ~ operator changes it to 0xFFFE.
Either way, t will be set to true because both 0xFFFF and 0xFFFE are non-zero.
What are you actually trying to accomplish with the ~ operator?
Thanks for your feedback, indeed the problem was using ~ instead of !, this solved the issue.
Regarding the bitSet suggestion, as I mentioned I am new to Arduino, I usually program on C, what is the advantage of the bitSet funtion over digitalWrite ?
adolfoe:
Thanks for your feedback, indeed the problem was using ~ instead of !, this solved the issue.
Regarding the bitSet suggestion, as I mentioned I am new to Arduino, I usually program on C, what is the advantage of the bitSet funtion over digitalWrite ?
bitSet() is another Arduino function (look here) that provides access to the bits of any register whereas digitalWrite() specifically targets the PORTn output register which is then mapped via the pin number you supply. digitalRead() maps the pin to the appropriate bit to the input register, PINn. When a write is made (bitSet) to the input register (PINn) it toggles the value on the pin of the corresponding output register. This is how fast toggles are made when performing software PWM and uses considerably fewer resources. It's perhaps at the next level in your road to understanding, but you can't stay at the same level forever.
adolfoe:
Regarding the bitSet suggestion, as I mentioned I am new to Arduino, I usually program on C, what is the advantage of the bitSet funtion over digitalWrite ?
BitSet is a convenience function for people new to C who haven't learned to use the bit-fiddling operators yet.