Hi,
I would like to know the difference between attachInterrupt(); and Interrupts();
Thanks for any help
Attach interrupts matches what pin will generate an interrupt with what that pin has to do to generate one, and what code to call when it does. That call is often known as an ISR or Interrupt Service Routine, which is the code you want to do when an interrupt has been generated.
Will turn on or enable, or activate the interrupt. You can even disable or turn off the interrupts as well with another call. I will leave it up to you to find that one in the Arduino reference which is just a click away in the Help menu
I have used the first one and never the second. When both are used together?
When the ISR generates an int variable for example. You need to, disable the interrupts then read the two bytes and then enable them again. This prevents an interrupt occurring between accessing the first byte and second bytes and getting a wrong value.
Ok, make sense. However I have seen some codes using only interrupts(); without any mentions about the ISR. They just say that the system will not work without interrupts();
What this means exactly?
Functions like millis(), Serial.print(), etc. do not function properly or at all without interrupts.
Some specific reason?
Yes, they specifically require interrupts.
Ok, thank you all for help me.