So great, you have learned how to use interrupts and as a small parenthesis, how to use the Internet,
don't know.
Let's forget about these debates and let's fully focus on the interrupts themselves.
So to correctly use interrupts.
You have to be careful and aware about what you can and can't do and what you should and shouldn't do.
Here is a quick list of the best practices and warnings that will help you when working with interests.
So first, an interim function does not return any result and does not receive any parameter.
So if you want to get on, modify some variables in your program, you will have to modify global variables
inside the internal function.
And note that for any viable you modify inside and interrupt, you should.
But the volatile key word in front of the data type, when you declare the variable now inside to enter
a function, you only want to write code that goes very fast to execute, for example, toggle available.
Basically, that's all you should aim to do.
In the interim, you should avoid doing any action in any threat.
Just use the Interop to toggle available and then in your void loop function, check for that variable
and execute annexion accordingly.
If you stay too long inside an interrupt, you might miss important data you receive in your voice function.
Or you could miss another interrupt that is deactivated while you are in the current one.
Now, if you want to use time functionality inside and interrupt, be extra careful.
First, the delay function won't work and delay microsurgeons.
Wolk's but as you want to optimize the speed, you definitely don't want to intentionally wait in the
interrupt, so don't use any of them.
Something very useful can be to get the time at the beginning of you in 30 minutes and micros will give
you the current time just before the entire function starts, but then inside it to interrupt function
minutes will not increase and micros will work accurately about one or two milliseconds and that's it.
The thing is, you don't want to spend even one millisecond on the interrupt.
You just want to toggle some level and then exit.
So just use Milice on micros to get the time at the beginning if you need it, but no more.
And finally, simple doesn't work in the Interent.
If you want to bring something when an interrupt was triggered, you will have to do it in the void
loop function and find a way to notify the loop when to interrupt was triggered to conclude.
You can see that there are many drawbacks and limitations about interrupt interrupt a powerful Ardino
function.
But to use with care, with the information you have here, you should be fine.
And because all those limitations and things to care about, it's best to use interrupt only when you
really need them when designing a new project.
Always ask yourself if what you want to achieve can just be done with pulling.
If yes, then use pulling.
If, however, you might miss some data using, pulling or get information a little bit too late, then
go with interrupts.